#!/usr/local/bin/descartes

<proxy #proxy>
	(::sys <getenv #p http_proxy> | <is #p "">)
	::sys <split #p1 #p "/">
	( <eq #p1 ()> <is #proxy "">
	 |
	  ::sys <car #p2 #p1>
	  <is "http:" #p2> ::sys <cadr #proxy #p1>
	 |
	  <is #proxy #p>
	 )
	;

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

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

// 不要な出力の抑止
? ::sys <PrintResultOff>;

<asahi #t3>
  ::sys <httpget #h #b "http://www.asahi.com/" <proxy _>> 　//asahi.comからhtmlを文字列と
						  //して取り出す
  ::sys <iconv #bd #b>　　　//ＵＴＦ８に変換
  ::sys <htmldecode #bu #bd>
  ::sys <htmltags #t #bu 'div id="HeadLine"' 'ul class="FollowLnk"'>
					//ヘッドラインの抜き出し
  ::sys <htmltags #t2 ::sys <car _ #t> "a href" "/a">
					//リンク(<a href ...> </a>)抜き出し
  ::sys <erasealltags #t3 #t2>		//いらないタグを消す
  ;


<yomiuri #t3>
  ::sys <httpget #h #b "http://www.yomiuri.co.jp/" <proxy _>>
  ::sys <iconv #bd #b>
  ::sys <htmldecode #bu #bd>
  ::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>
  ;

<mainich #t3>
  ::sys <httpget #h #b "http://mainichi.jp/" <proxy _>>
  ::sys <iconv #bd #b>
  ::sys <htmldecode #b #bd>
  ::sys <htmltags #t #b 'header class="topicsHeader"' 
			'div class="topicsPhotoWrapper"'>
  ::sys <htmltags #t2 ::sys <car _ #t> "a href" "/a">
  ::sys <erasealltags #t3 #t2>
  ;


<sankei #list>
  ::sys <httpget #h #b "http://sankei.jp.msn.com/" <proxy _>>
  ::sys <iconv #bd #b>
  ::sys <htmldecode #b #bd>
  ::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>>
  ;


<tokyo #t3>
  ::sys <httpget #h #b "http://www.tokyo-np.co.jp/" <proxy _>>
  ::sys <iconv #bd #b>
  ::sys <htmldecode #bu #bd>
  ::sys <htmltags #t #bu 'div id="NewsArea"' "/ul">
  ::sys <htmltags #t2 ::sys <car _ #t> "a href" "/a">
  ::sys <erasealltags #t3 #t2>
  ;

<slashdotj #list>
  ::sys <httpget #h #b "http://slashdot.jp/" <proxy _>>
  ::sys <iconv #bd #b>
  ::sys <htmldecode #bu #bd>
  ::sys <htmltags #t #bu 'body' '/body'>
  ::sys <htmltags #t2 #t 'span id="title-' '/span'>
  ::sys <erasealltags #t3 #t2>
  ::sys<car #t4 #t3>
  <first8 #list #t4>
  ;

<displaynews>
  <asahi #asahi>
  <yomiuri #yomiuri>
/*
  <mainich #mainichi>
  <sankei #sankei>
  <tokyo #tokyo>
*/
  <slashdotj #slashdotj>

  <print "朝日新聞 www.asahi.com ヘッドライン">
  <printlistnl #asahi>
  <print>

  <print "読売新聞 www.yomiuri.co.jp ヘッドライン">
  <printlistnl #yomiuri>
  <print>
/*
  <print "毎日新聞 mainichi.jp ヘッドライン">
  <printlistnl #mainichi>
  <print>

  <print "産経msn sankei.jp.msn.com ヘッドライン">
  <printlistnl #sankei>
  <print>

  <print "東京新聞 www.tokyo-np.co.jp ヘッドライン">
  <printlistnl #tokyo>
  <print>

  <print "slashdot.jp スラッシュドット ヘッドライン">
  <printlistnl #slashdotj>
  <print>
*/
  ;


