标签:class gen www urllib webkit 实现 lib 并保存 pen
实现百度搜索并保存到本地
User_Agent = ‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.81 Safari/537.36‘ import urllib2 import urllib url = "https://www.baidu.com/s?wd=" key = "博客园" key_code = urllib.quote(key) url_all = url + key_code req = urllib2.Request(url_all) req.add_header(‘User-Agent‘,AA) data = urllib2.urlopen(req).read() print data #在F盘新建一个11文件夹和11.html fh = open("F:/11/11.html","wb") fh.write(data) fh.close()
Python实现百度搜索并保存到本地示例,Python实现百度搜索
标签:class gen www urllib webkit 实现 lib 并保存 pen
原文地址:http://www.cnblogs.com/xuchunlin/p/6971725.html