抓取百度贴吧(注意你所评价的程序是用Python 2还是Python 3书写的,分别使用print语句和print()函数)“http://tieba.baidu.com/p/1000000000”至“http://tieba.baidu.com/p/1000000009”这10个页面并以1000000000.html~1000000009.html这样的文件名保存到本地硬盘上(提示:文件写入使用wb模式)。
address=range(0,10)
for i in xrange(0,10):
address[i]=str(1000000000+i)
for i in xrange(0,10):
import urllib
r = urllib.urlopen('http://tieba.baidu.com/p/'+address[i])
html = r.read()
f = open(address[i]+'.html','wb')
f.writelines(html)
f.close()