这个程序很早以前就写过了,而且是参考的别人的写,具体谁的发
-*- coding:utf-8 -*-
# file:weather.py
# by Lee, 2010-1-11
"""
抓取天气预报信息,并通过pyfetion发送短信通知
"""
import os
import re
import urllib
import sys
import time
from PyFetion import *
def GetWeather():
try:
# 获取网页源文件
sock = urllib.urlopen("http://qq.ip138.com/weather/guangdong/DongGuan.htm")
strhtml = sock.read()
strhtml = unicode(strhtml, 'gb2312','ignore').encode('utf-8','ignore')
# 正则式取温度信息
theGrades = re.findall('''(\d+)℃''', strhtml)
# 获取天气描述信息
weathers = re.findall(''' (.*)''',strhtml)
25 # 定义时间格式
26 this_date = str(time.strftime("%Y/%m/%d %a"))
27 now = int(time.time())
28 sec = 24*60*6