또 하 나 는 날씨 스 크 립 트.

2079 단어 htmlPHP각본J#
"""          """
import re,urllib,urllib2
s='http://search.weather.com.cn/static/url.php'
body={}
n=raw_input('please input your local street tel number:     ')
print '

' body['cityinfo']=n ss=urllib.urlencode(body) tem=urllib.urlopen(s,ss).read() url=re.findall(r'URL=(.*?)">',tem)[0] tem=urllib.urlopen(url).read() w=open('weather.html','w') w.write(tem) w.close() com=re.compile(r'<dt class="date">(.*?)<span class="f888">.*?<h3><strong>(.*?)<\/strong>\((.*?)\)<\/h3>.*?<dt>( )<\/dt>.*?<dd><strong>.*?<a>(\d*)<\/a>',re.I|re.M|re.S) temp=com.findall(tem) for i in temp: for j in i: t=unicode(j,'utf8','ignore') print t, com=re.compile(r'<div class="box_contenttodayinwea" id="c_1_1">(.*?) ',re.I|re.M|re.S) temp=com.findall(tem) for i in temp: print '
' ch=u' ' print ch, com=re.compile(r'>(.*?)<',re.I|re.M|re.S) t=com.findall(i) for j in t: j=j.strip() tt=j.replace('\t','') tt=tt.replace('&nbsp;','') tt=unicode(tt,'utf8','ignore') print tt, com=re.compile(r'<div class="fut_weatherbox7">(.*?)<\/div>',re.I|re.M|re.S) temp=com.findall(tem) for i in temp: print '
' com=re.compile(r'>(.*?)<',re.I|re.M|re.S) t=com.findall(i) for j in t: tt=j.replace('\t','') tt=tt.strip() tt=tt.replace('&nbsp;','') tt=unicode(tt,'utf8','ignore') print tt, n=raw_input('

finished')

좋은 웹페이지 즐겨찾기