首页 > 代码库 > 积累 自定义 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 函数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。