您的位置:首页 > 编程语言

代码笔记 | 自动爬取百度贴吧的网页

2016-09-01 15:21 141 查看
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)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  python