summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-07-02 22:09:48 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2003-07-02 22:09:48 +0800
commitd153113dbce613fee88a894a6a19579b95e15658 (patch)
tree9a8f859f245a35624c7692d33f03398897e29403 /util
parent563d4f34e73443bde2cbc64800908244a3186d78 (diff)
downloadpttbbs-d153113dbce613fee88a894a6a19579b95e15658.tar
pttbbs-d153113dbce613fee88a894a6a19579b95e15658.tar.gz
pttbbs-d153113dbce613fee88a894a6a19579b95e15658.tar.bz2
pttbbs-d153113dbce613fee88a894a6a19579b95e15658.tar.lz
pttbbs-d153113dbce613fee88a894a6a19579b95e15658.tar.xz
pttbbs-d153113dbce613fee88a894a6a19579b95e15658.tar.zst
pttbbs-d153113dbce613fee88a894a6a19579b95e15658.zip
*** empty log message ***
git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@997 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'util')
-rw-r--r--util/udnnews.pl61
1 files changed, 33 insertions, 28 deletions
diff --git a/util/udnnews.pl b/util/udnnews.pl
index 99d690c3..b09944b0 100644
--- a/util/udnnews.pl
+++ b/util/udnnews.pl
@@ -20,9 +20,9 @@ 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]")});
+ title => strreplace(FormatChinese($_->[1])),
+ owner => 'udnnews.',
+ content => getudnnewscontent("http://www.udn.com/NEWS/FOCUSNEWS/$_->[0]")});
}
sub strreplace
@@ -50,11 +50,16 @@ sub getudnnewscontent($)
$content = strreplace($content);
undef $ret;
foreach( split(/\n/, $content) ){
- s/ //g;
- $ret .= FormatChinese($_, 60). "\n" if( $_ );
+ s/ //g;
+ $ret .= FormatChinese($_, 60). "\n" if( $_ );
}
- return "※ [轉錄自 $url ]\n\n$ret\n\n".
- "--\n感謝 http://www.udn.com/ 熱情贊助";
+ return
+ "作者: udnnews.(聯合新聞) 看板: udnnews".
+ "標題: ".
+ "時間: 即時".
+ "※ [轉錄自 $url ]\n\n$ret\n\n".
+ "--\n$param->{title}\n 聯合新聞網 http://www.udn.com/ 獨家授權批踢踢實業坊轉載 ".
+ "\n 未經允許請勿擅自使用 ";
}
sub getudnnewstitle($)
@@ -63,9 +68,9 @@ sub getudnnewstitle($)
my($url, $title);
open FH, "$LYNX -source http://www.udn.com/NEWS/FOCUSNEWS/ | $GREP '<font color=\"#FF9933\">' |";
while( <FH> ){
- ($url, $title) = $_ =~ m|<font color="#FF9933">.</font><a href="(.*?)"><font color="#003333">(.*?)</font></a><font color="#003333">|;
- $title =~ s/<.*?>//g;
- push @{$ra_titles}, [$url, $title];
+ ($url, $title) = $_ =~ m|<font color="#FF9933">.</font><a href="(.*?)"><font color="#003333">(.*?)</font></a><font color="#003333">|;
+ $title =~ s/<.*?>//g;
+ push @{$ra_titles}, [$url, $title];
}
close FH;
return @{$ra_titles};
@@ -77,26 +82,26 @@ sub FormatChinese
my($i, $ret, $count, $s);
return if( !$str );
for( $i = 0 ; $i < length($str) ; ++$i ){
- if( ord(substr($str, $i, 1)) > 127 ){
- $ret .= substr($str, $i, 2);
- ++$i;
- }
- else{
- for( $count = 0, $s = $i ; $i < length($str) ; ++$i, ++$count ){
- last if( ord(substr($str, $i, 1)) > 127 );
- }
- --$i;
- $ret .= ' ' if( $count % 2 == 1);
- $ret .= substr($str, $s, $count);
- }
+ if( ord(substr($str, $i, 1)) > 127 ){
+ $ret .= substr($str, $i, 2);
+ ++$i;
+ }
+ else{
+ for( $count = 0, $s = $i ; $i < length($str) ; ++$i, ++$count ){
+ last if( ord(substr($str, $i, 1)) > 127 );
+ }
+ --$i;
+ $ret .= ' ' if( $count % 2 == 1);
+ $ret .= substr($str, $s, $count);
+ }
}
if( $length ){
- $str = $ret;
- undef $ret;
- while( $str ){
- $ret .= substr($str, 0, $length)."\n";
- $str = substr($str, $length);
- }
+ $str = $ret;
+ undef $ret;
+ while( $str ){
+ $ret .= substr($str, 0, $length)."\n";
+ $str = substr($str, $length);
+ }
}
return $ret;
}