注意
1.python文件读写
infile.write(data)
它返回一个整数值,千万别写错
2.python.format记住它
urls = [https://www /index_{}.html”.format( str(i)for i in range(1,5)]
3,关于爬取百度搜索结果
baseUrl = ‘http://www.baidu.com/s’
page = 1 #第几页
data = {‘wd’:word,’pn’:str(page-1)+’0’,’tn’:’baidurt’,’ie’:’utf-8’,’bsst’:’1’}
data = parse.urlencode(data)
url = baseUrl+’?’+data