一个天气预报的脚本
- bones7456
- 帖子: 8495
- 注册时间: 2006-04-12 20:05
- 来自: 杭州
- 联系:
一个天气预报的脚本
闲来无事,写了天气预报的脚本,与大家分享。
本人菜鸟,如有任何问题或建议,欢迎指正。谢谢。
数据来自 http://weather.265.com
20080524更新,感谢bthink发现265的改版消息。
本人菜鸟,如有任何问题或建议,欢迎指正。谢谢。
数据来自 http://weather.265.com
20080524更新,感谢bthink发现265的改版消息。
- 附件
-
- weather.tar
- 脚本
外加一个城市代码文件 - (10 KiB) 已下载 258 次
上次由 bones7456 在 2008-05-24 19:14,总共编辑 3 次。
关注我的blog: ε==3
- ofewiofewo
- 帖子: 547
- 注册时间: 2007-06-02 14:56
- zhan
- 帖子: 1880
- 注册时间: 2005-08-15 0:04
- 来自: 南7技校
无聊的人又多了一个.
http://rafb.net/p/APZfJp42.html
python 版的,比 bash 的好看点...
http://rafb.net/p/APZfJp42.html
代码: 全选
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import urllib, re, sys
def getcitycode():
conn=urllib.urlopen("http://weather.265.com/get_weather.php?action=get_city")
citysrc=conn.read().decode("gbk").encode("utf8")
conn.close()
citycode=re.findall('[0-9]{5}', citysrc)[0]
return citycode
def getweather(code):
url="http://weather.265.com/weather/"+code+".htm"
conn=urllib.urlopen(url)
weasrc=conn.read().decode("gbk").encode("utf8")
conn.close()
wea=re.findall('show_weather\("(.*)"\)', weasrc)[0].split("'")
weather=[item for item in wea if item !="," and ")" not in item and "(" not in item]
city=wea[0].split('"')[0]
option=[u'今天:',u'上午:',u'下午:',u'晚上:',u'明天:',u'上午:',u'下午:',u'晚上:']
#print "\n".join(weather)
index=0
print u'城市:',city
while index < (len(option)):
print option[index],weather[index]
index=index+1
if __name__=='__main__':
try:
code=sys.argv[1]
except:
code=getcitycode()
getweather(code)
飞得高,飞得低,学习再学习,多少大秘密!
http://zhan.blog.ubuntu.org.cn
http://zhan.blog.ubuntu.org.cn
-
- 帖子: 11
- 注册时间: 2007-03-25 14:08
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
kyowu 写了:是这样用么?
解压后,
chmod -x weather
./weather
为什么提示
bash: ./weather:Permission denied
???
代码: 全选
chmod u+x weather
^_^ ~~~
要理解递归,首先要理解递归。
地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
要理解递归,首先要理解递归。
地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
-
- 帖子: 161
- 注册时间: 2007-03-08 19:12
- 联系:
-
- 帖子: 11
- 注册时间: 2007-03-25 14:08
- Beetle
- 帖子: 1637
- 注册时间: 2005-10-14 16:55
- 系统: OS X
- 来自: 江苏
- 联系: