最近の更新 (Recent Changes)

2014-01-01
2013-01-04
2012-12-22
2012-12-15
2012-12-09

Wikiガイド(Guide)

サイドバー (Side Bar)


← 前のページに戻る

1.5 WWW版ニュースヘッドライン表示プログラム

1.5.1 ソース


#!/usr/local/bin/descartes

<proxy "">;

? ::sys <PrintResultOff>;

<first8 () () _>;
<first8 () _ 8>;

<first8 (#i :#r) (#i :#rest) #n>
        <#n1 = #n + 1>
        <first8 #r #rest #n1>
        ;
<first8 #out #l>
        <first8 #out #l 0>
        ;


? <print "Content-type: text/html">
  <print>
  <print "<html>">
  <print "<head>">
  <print "<title>ニュースヘッドライン</title>">
  <print "</head>">
  <print '<body>'>
  <print "<H1>ニュースヘッドライン</H1>">
  <print "<p>">
  ;

<printl ()>;
<printl (#l1 : #l)>
        <print "<li>" #l1 "</li>">
        <printl #l>
        ;

? ::sys <httpget #h #b "http://www.asahi.com/" <proxy _>>
  ::sys <iconv #bu #b "UTF-8" "EUC-JP">
  ::sys <htmltags #t #bu 'div id="HeadLine"' 'ul class="FollowLnk"'>
  ::sys <htmltags #t2 ::sys <car _ #t> "a href" "/a">
  ::sys <erasealltags #t3 #t2>
  <print "朝日新聞 www.asahi.com ヘッドライン<BR>">
  <print "<ul>">
  <printl #t3>
  <print "</ul>">
  ;


? ::sys <httpget #h #b "http://www.yomiuri.co.jp/" <proxy _>>
  ::sys <iconv #bu #b "UTF-8" "SJIS">
  ::sys <htmltags #t #bu 'div class="headline-def"' "/ul">
  ::sys <erasetags #t1 #t
        'img src="/g/d.gif" width="1" height="1" alt="特集"' "/li" >
  ::sys <htmltags #t2 ::sys <car _ #t1> "a href" "/a">
  ::sys <erasealltags #t3 #t2>
  <print "読売新聞 www.yomiuri.co.jp ヘッドライン<BR>">
  <print "<ul>">
  <printl #t3>
  <print "</ul>">
  <print>
  ;

? ::sys <httpget #h #b "http://mainichi.jp/" <proxy _>>
  ::sys <htmltags #t #b 'header class="topicsHeader"'
                        'div class="topicsPhotoWrapper"'>
  ::sys <htmltags #t2 ::sys <car _ #t> "a href" "/a">
  ::sys <erasealltags #t3 #t2>
  <print "毎日新聞 mainichi.jp ヘッドライン<BR>">
  <print "<ul>">
  <printl #t3>
  <print "</ul>">
  <print>
  ;


? ::sys <httpget #h #b "http://sankei.jp.msn.com/" <proxy _>>
  ::sys <htmltags #t #b 'div class="RightPart"' 'div id="ADkinkoku"'>
  ::sys <htmltags #t2 ::sys <car _ #t> "a href" "/a">
  ::sys <erasealltags #t3 #t2>
  ::sys <cons #list ::sys <car _ #t3> ::sys <cddr _ #t3>>
  <print "産経msn sankei.jp.msn.com ヘッドライン<BR>">
  <print "<ul>">
  <printl #list>
  <print "</ul>">
  <print>
  ;


? ::sys <httpget #h #b "http://www.tokyo-np.co.jp/" <proxy _>>
  ::sys <iconv #bu #b "UTF-8" "SJIS">
  ::sys <htmltags #t #bu 'div id="NewsArea"' "/ul">
  ::sys <htmltags #t2 ::sys <car _ #t> "a href" "/a">
  ::sys <erasealltags #t3 #t2>
  <print "東京新聞 www.tokyo-np.co.jp ヘッドライン<BR>">
  <print "<ul>">
  <printl #t3>
  <print "</ul>">
  <print>
  ;

? ::sys <httpget #h #bd "http://slashdot.jp/" <proxy _>>
  ::sys <htmltags #t #bd 'body' '/body'>
  ::sys <htmltags #t2 #t 'span id="title-' '/span'>
  ::sys<car #t3 #t2>
  ::sys <erasealltags #t4 #t3>
  <first8 #list #t4>
  <print "slashdot.jp スラッシュドット ヘッドライン<BR>">
  <print "<ul>">
  <printl #list>
  <print "</ul>">
  ;

? ::sys <sleep 3>;

? <print "</p>">
  <print "</body>">
  <print "</html>">
  ;