- 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)
- #该片段来自于http://www.codesnippet.cn/detail/0807201614840.html
来源: http://www.codesnippet.cn/detail/0807201614840.html