#!/usr/bin/perl # # 請註意! # 本程式版權屬於 PttBBS , # 但只表示您可以公開免費取得本程式, # 並不表示您可以使用本程式. # # 本程式將直接連至 udnnews網站取得當前新聞, # 而新聞內容的版權是屬於 聯合新聞網 所有. # 亦即, 您若沒有聯合新聞網之書面授權, # 您並「不能」使用本程式下載該網新聞. # use lib '/home/bbs/bin/'; use LocalVars; use strict; use vars qw/@titles/; chdir '/home/bbs'; getudnnewstitle(\@titles); foreach( @titles ){ postout({brdname => 'udnnews', title => strreplace(FormatChinese($_->[1])), owner => 'udnnews.', content => getudnnewscontent("http://www.udn.com/NEWS/FOCUSNEWS/$_->[0]")}); } sub strreplace { my($str) = @_; $str =~ s/十/十/g; $str =~ s/卅/卅/g; $str =~ s/游錫\&\#22531\;/游揆/g; return $str; } sub getudnnewscontent($) { my($url) = @_; my($buf, $content, $ret); $buf = `$LYNX -source '$url'`; ($content) = $buf =~ m|(.*?)|s; # ($content) = $buf =~ m|
(.*?) /\n/gi;
$content =~ s/<.*?>//g;
$content =~ s/\r//g;
$content =~ s/\n\n\n/\n\n/g;
$content =~ s/\n\n\n//g;
$content = strreplace($content);
undef $ret;
foreach( split(/\n/, $content) ){
s/ //g;
$ret .= FormatChinese($_, 60). "\n" if( $_ );
}
return "※ [轉錄自 $url ]\n\n$ret\n\n".
"--\n感謝 http://www.udn.com/ 熱情贊助";
}
sub getudnnewstitle($)
{
my($ra_titles) = @_;
my($url, $title);
open FH, "$LYNX -source http://www.udn.com/NEWS/FOCUSNEWS/ | $GREP '' |";
while( |s if( !$content );
$content =~ s/
/\n/g;
$content =~ s/