爬虫设置代理
来源:互联网 发布:java线程yield 编辑:程序博客网 时间:2024/05/21 07:58
介绍两种方法:requests、urllib2
import urllib2import lxml.htmlimport requestsurl = 'http://www.ip181.com/'proxy = {'http': 'http://111.13.7.42:82'}'''opener = urllib2.build_opener(urllib2.ProxyHandler(proxy))urllib2.install_opener(opener)html = urllib2.urlopen(url).read()'''html = requests.get(url, proxies=proxy).contenttree = lxml.html.fromstring(html)content = tree.cssselect('div.panel-info:nth-child(2) > div:nth-child(2) > div:nth-child(1) > div:nth-child(2)')[0].textprint content
阅读全文
0 0
- 爬虫代理ip设置
- 爬虫代理ip设置
- 爬虫设置代理
- 浅谈Python爬虫代理设置
- 详谈Python爬虫代理设置
- HttpClient设置代理做网络爬虫
- Python爬虫设置代理IP爬取知乎图片
- Python爬虫技巧---设置代理IP
- selenium+python设置爬虫代理IP
- 爬虫代理
- java爬虫(使用jsoup设置代理,抓取网页内容)
- Python爬虫设置动态代理(在线获取)
- java爬虫代理
- 爬虫 代理问题
- 爬虫自动更换代理
- python网页爬虫代理
- Python爬虫代理池
- python爬虫07--代理
- 二叉排序树基本用法
- 【模式识别】贝叶斯分类器的C++实现
- 监听器
- ffmpeg 解码 png apng 图片
- jiebaR中文分词,从入门到喜欢
- 爬虫设置代理
- centos7 五大查找常用命令
- 更改Eclipse下Tomcat的部署目录
- sqlserver 还原出错
- 集体婚礼
- *块状链表
- LeetCode 50 Pow(x, n)
- 儿子长大后
- 1175: ACM"水题"