import string,urllib2
def baidu(url,bp,ep):
for i in range(bp,ep+1):
sName=string.zfill(i,5)+'.html'
print 'Download' + str(i) + 'page,store named' + sName + '......'
f=open(sName,'w+')
m=urllib2.urlopen(url+str(i)).read()
f.write(m)
f.close()
bdurl=str(raw_input(u'Please input the url, cut the number:\\n'))
bp=int(raw_input(u'Plase input the start page:\\n'))
ep=int(raw_input(u'Plase input the end page:\\n'))
baidu(bdurl,bp,ep)
代码笔记 | 自动爬取百度贴吧的网页
最新推荐文章于 2024-09-05 10:28:02 发布