标签:
#saved the baidu tieba webpage import string, urllib2 def baidu_tieba(url,begin_page,end_page): for i in range(begin_page,end_page+1,50): sName=string.zfill(i,5)+‘.html‘ print ‘You are downloading the No: ‘ +str(i)+‘ web page,and will be saved as ‘+sName+‘.....‘ f=open(sName,‘w+‘)# New open the file with ‘w‘ m=urllib2.urlopen(url+str(i)).read()#open the web page and read it f.write(m)#write the web page to new file f.close()#cloase file bdurl=str(raw_input(u‘please input tieba site, delete pn=number:\n‘)) begin_page=int(raw_input(‘enter start page number:\n‘)) end_page=int(raw_input(‘enter end page number:\n‘)) baidu_tieba(bdurl,begin_page,end_page)
标签:
原文地址:http://www.cnblogs.com/sinbad-li/p/5484803.html