首页 > 代码库 > webspider

webspider

 

<style></style><style></style><style></style><style></style><style></style><script id="wiz_todo_script_id" charset="utf-8" type="text/javascript" src="file:///D:\Program Files\WizNote\WizTools\htmleditor\todo.js"></script><script id="wiz_img_resize_script_id" charset="utf-8" type="text/javascript" src="file://D:\Program Files\WizNote\WizTools\htmleditor\dragresize.js"></script><style></style><style></style>
 

webspider.py

python 抓取每日一文文章

import urllib2# get webpageheaders = {‘User-Agent‘:‘Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36‘}fd   = urllib2.Request(‘http://meiriyiwen.com/‘,headers = headers)  data = http://www.mamicode.com/urllib2.urlopen(fd).read()# save as a filef = open(‘issue.htm‘, ‘w‘)f.write(data)f.close()

webspider