作者beagle (请勿拍打喂食)
看板PttCurrent
标题weather
时间Mon Feb 9 14:52:14 2004
这是现在 cookie 使用的的 weather script ... 有两行过长请接起来... :p
里面是用 pdftotext 把中央气象局的 pdf 文字预报单转换成 text ...
这个 utility 叫 Xpdf 3.00, 在 redhat 或 debian linux 都有附,
可以直接把气象局 .pdf 里面的文字部份取出...
FreeBSD 的话, 用 ports 就可以轻松装上的样子... 我没试过...
我是抓 source code 回来 compile 成 text only ,
再装 Redhat 的中文转档 map files ... 因为我是用 Slackware ...
--
#!/usr/bin/perl
# 如果发出的 post 没有气象报告而是说 URL 找不到,则确定一下能不能看到
# 中央气象局的 WWW 及 URL 是否正确。
# 理论上适用所有 Eagle BBS 系列。
# -- Beagle Apr 13 1997
#require "/usr/lib/perl5/timelocal.pl";
# 输出到 Test 版
open(BBSPOST, "| /home/bbs/bin/bbspost post /home/bbs/boards/Test");
# 输出到萤幕上 Debug
#open(BBSPOST, "| cat");
# 日期
open(DATE, "date +'%a %b %d %T %Y' |");
$date = <DATE>;
chop $date;
close DATE;
# Header
print BBSPOST "\n\nPosted By: cookie (我是可爱的小饼乾喔!)\n";
print BBSPOST "Title: 明日白天天气预报\n";
print BBSPOST "Date: $date\n\n";
# 内容
# 天气
system("wget -q -C off -O /tmp/weather-report.pdf
http://www.cwb.gov.tw/V4/
weather/text/Data/W03.pdf");
open(WEATHER, "/usr/local/bin/pdftotext -layout -enc Big5 /tmp/weather-repo
rt.pdf - | tr -d \\\\f |");
while (<WEATHER>) {
print BBSPOST if ($_ ne "\n")
}
print BBSPOST "\n";
# fortune | autob5 -o big5
open(FORTUNE, "/usr/games/fortune |");
print BBSPOST <FORTUNE>;
close FORTUNE;
# 签名档
print BBSPOST "\n--\n";
print BBSPOST "我是可爱的小饼乾... 我是这里的小管家... *^_^*\n";
print BBSPOST "--\n";
print BBSPOST "[Origin: ◎蓝莓松饼屋◎] [From: [蓝莓松饼屋] ] ";
print BBSPOST "[Login: **] [Post: **]\n";
close BBSPOST;
--
I don't write Perl, I speak it.
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 211.21.54.210