看板 PttCurrent 關於我們 聯絡資訊
這是現在 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