python编程篇之爬虫(一)
最简单的一个爬虫,爬取百度首页
import urllib
url = "http://www.baidu.com"
data = urllib.request.urlopen(url).read().decode('utf-8','ignore')
# print(data)
with open('E:/testFile/baidu.html', 'w', encoding='utf-8') as fh:
fh.write(data)
将爬取到的数据存储在本地文件上