首页 > 代码库 > 积累 自定义 Python 函数

积累 自定义 Python 函数

简单爬虫常用

#获取网络内容def getWebContent(url):    headers = {‘User-Agent‘:‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_0) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11‘}    req = urllib2.Request(url, headers=headers)    html = urllib2.urlopen(req).read()    return html#下载图片def downloadImage(imageUrl,localName):    data = http://www.mamicode.com/urllib2.urlopen(imageUrl).read()>

  

积累 自定义 Python 函数