您的位置:首页 > Web前端

利用PyWapFetion发免费天气短信

2013-10-30 21:01 155 查看
用到的第三方资源:

python使用wap飞信的模块:https://github.com/whtsky/PyWapFetion 目前能用。很简单。

解析RSS文件:http://code.google.com/p/feedparser/ 使用方法可以看Documentation。

天气预报源:http://weather.raychou.com/?/list/ 找到自己的城市,生成RSS地址。

我的代码forecast.py只有几行:

#!/usr/bin/python
#-*-coding:utf-8 -*-
import PyWapFetion
import feedparser
weather_source = "http://weather.raychou.com/?/detail/57494/rss"
d=feedparser.parse(weather_source)
send_content = d.feed.title + "\n明天:" + d.entries[1].description + "\n后天:" +  d.entries[2].description
print send_content
PyWapFetion.send("15171456221","mypasswd","15171456221",send_content)


如果要每天定时发送,那么就将这个脚本使用Linux的计划任务Crontab定时执行。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: