一个天气预报的脚本
闲来无事,写了天气预报的脚本,与大家分享。
本人菜鸟,如有任何问题或建议,欢迎指正。谢谢。
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
#!/bin/bash #Copyright (c) 2007 bones7456 (bones7456@gmail.com) #License: GPLv3 #version 20080524 #城市代码,留空可自动检测(自动检测不一定精确),城市代码可在 http://weather.265.com 上查询,是个5位的数字 #city=58457 if [ -n "$city" ] ;then wid=${city} else wget -q -O /tmp/weather.html 'http://www.265.com/lookupcity'; wid=`awk -F "'" '{print $2}' /tmp/weather.html`; fi #echo ${wid}; wget -q -O /tmp/weather.html "http://www.265.com/weather/${wid}.htm"; str=`iconv -f gbk -t utf8 /tmp/weather.html | grep 'show_weather' | sed -e 's/show_weather("//g'|sed -e 's/),\ "hd\.htm.*//g' | sed -e 's/new Array(//g' | sed -e "s/[\"|\ ]//g" | sed -e "s/,'/ /g" |sed -e "s/'//g"`; #echo ${str}; AnArray=( ${str} ); time=`date +%k`; if [ ${time} -gt 18 ] ; then echo ${AnArray[0]}: ${AnArray[1]} 今晚:${AnArray[4]};明天:${AnArray[6]} elif [ ${time} -gt 12 ] ; then echo ${AnArray[0]}: ${AnArray[1]} 下午:${AnArray[3]};晚上:${AnArray[4]} else echo ${AnArray[0]}: ${AnArray[1]} 上午:${AnArray[2]};下午:${AnArray[3]} fi rm -f /tmp/weather.html; exit 0; |
bones7456 : 语音播报天气的脚本 在 2008年10月03日 19:36 说:【 】
[…] 我以前写的一个天气预报脚本,由xiooli同学完成了语音部分,嘿嘿,效果还不错的哦~ 下载地址: http://ftp.ubuntu.org.cn/home/xiooli/say_weather.tar.gz 或 http://linuxfire.com.cn/~lily/say_weather.tar.gz […]
Shellex 在 2009年03月28日 11:14 说:【 】
没有负温度的语音
bones7456 在 2009年03月29日 09:51 说:【 】
呃…漏了…