From 5a04bc91540459e854225d7f98f3f7eec080f9b5 Mon Sep 17 00:00:00 2001 From: victor Date: Thu, 12 Feb 2004 03:20:37 +0000 Subject: weather predict tomorrow git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1528 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/weather.perl | 35 ++++++++++++++++++----------------- util/weather.sh | 3 ++- 2 files changed, 20 insertions(+), 18 deletions(-) (limited to 'util') diff --git a/util/weather.perl b/util/weather.perl index 5edc147a..690c84fa 100644 --- a/util/weather.perl +++ b/util/weather.perl @@ -10,28 +10,29 @@ use lib '/home/bbs/bin'; use LocalVars; -open(BBSPOST, "| bin/webgrep>etc/weather.tmp"); -# 日期 -open(DATE, "date +'%a %b %d %T %Y' |"); -$date = ; -chop $date; -close DATE; +weather_report('etc/weather.today', 'ftp://ftpsv.cwb.gov.tw/pub/forecast/W002.txt'); +weather_report('etc/weather.tomorrow', 'ftp://ftpsv.cwb.gov.tw/pub/forecast/W003.txt'); + +sub weather_report +{ + my ($file, $link) = @_; + open(BBSPOST, "| $file"); # Header # 內容 #open(WEATHER, "$LYNX -assume_charset=big5 -assume_local_charset=big5 -dump http://www.cwb.gov.tw/V3.0/weather/text/W03.htm |"); -open(WEATHER, "$LYNX -assume_charset=big5 -assume_local_charset=big5 -dump -nolist ftp://ftpsv.cwb.gov.tw/pub/forecast/W002.txt|"); + open(WEATHER, "$LYNX -assume_charset=big5 -assume_local_charset=big5 -dump -nolist $link|"); -while () { - print BBSPOST if ($_ ne "\n"); -} -close WEATHER; + while () { + print BBSPOST if ($_ ne "\n"); + } + close WEATHER; # 簽名檔 -print BBSPOST "\n--\n"; -print BBSPOST "我是beagle所有可愛的小餅乾...跨海為Ptt服務\n"; -print BBSPOST "--\n"; -print BBSPOST "☆ [Origin: ◎果醬小站◎] [From: [藍莓鬆餅屋] ] "; - -close BBSPOST; + print BBSPOST "\n--\n"; + print BBSPOST "我是beagle所有可愛的小餅乾...跨海為Ptt服務\n"; + print BBSPOST "--\n"; + print BBSPOST "☆ [Origin: ◎果醬小站◎] [From: [藍莓鬆餅屋] ] "; + close BBSPOST; +} diff --git a/util/weather.sh b/util/weather.sh index 315b0ec3..58a1bdbf 100644 --- a/util/weather.sh +++ b/util/weather.sh @@ -2,4 +2,5 @@ # $Id: weather.sh,v 1.1 2002/03/07 15:13:46 in2 Exp $ # bin/weather.perl -bin/post Record 全省各地天氣預報 [氣象小姐] etc/weather.tmp +bin/post Record 全省今日各地天氣預報 [氣象小姐] etc/weather.today +bin/post Record 全省明日各地天氣預報 [氣象小姐] etc/weather.tomorrow -- cgit v1.2.3