python selenium Frefox使 用代理访问网页
2014-12-12 14:05
288 查看
因故需要代理访问网页,结果发现用selenium drive启动的firefox居然不会去读手动设置的代理,设置如下:
socks类型的代理
profile = webdriver.FirefoxProfile()
profile.set_preference('network.proxy.type', 1) #默认值0,就是直接连接;1就是手工配置代理。
profile.set_preference('network.proxy.socks', ip)
profile.set_preference('network.proxy.socks_port', port)
profile.set_preference('network.proxy.ssl',ip)
profile.set_preference('network.proxy.ssl_port', port)
profile.update_preferences()
browser = webdriver.Firefox(profile)
browser.get("http://www.ip138.com")
如果是http类型的代理,则将proxy.socks改为proxy.http
=========================好记性不如烂笔头==========
socks类型的代理
profile = webdriver.FirefoxProfile()
profile.set_preference('network.proxy.type', 1) #默认值0,就是直接连接;1就是手工配置代理。
profile.set_preference('network.proxy.socks', ip)
profile.set_preference('network.proxy.socks_port', port)
profile.set_preference('network.proxy.ssl',ip)
profile.set_preference('network.proxy.ssl_port', port)
profile.update_preferences()
browser = webdriver.Firefox(profile)
browser.get("http://www.ip138.com")
如果是http类型的代理,则将proxy.socks改为proxy.http
=========================好记性不如烂笔头==========
相关文章推荐
- python]用urllib2设置代理访问网页
- Python 设置 IP 代理 访问网页 ( 用户名密码验证代理 )
- Selenium-Webdriver(python) (五) --- 电脑模拟手机访问手机版网页
- Python3中使用代理访问网页
- python3.0学习七: 用代理访问网页
- Python2设置用户代理User Agent访问网页
- Python 通过ISA 代理访问互联网报错 HTTP Error 407
- 黄聪:python访问抓取网页常用命令(保存图片到本地、模拟POST、GET、中文编码问题)
- HttpClient4基础1--通过匿名代理访问网页
- C# webBrowser 通过代理访问网页
- 使用Python访问并下载网页内容
- Python 通过代理访问网络
- 通过python多线程访问网页
- python通过代理刷网页点击量
- python 使用 mechanize 模拟浏览器访问网页
- [python相关]python 访问网页
- 使用Python访问并下载网页内容
- python使用代理读取网页
- 使用Python访问并下载网页内容
- 用于网页判断的智能代理技术的简单实现------------基于python实现(网络爬虫)