selenium firefox设置代理
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.set_preference('network.proxy.type', 1)
profile.set_preference('network.proxy.http', 'proxy_url')
profile.set_preference('network.proxy.http_port', 3128)
profile.set_preference('network.proxy.ssl', 'proxy_url')
profile.set_preference('network.proxy.ssl_port', 3128)
profile.update_preferences()
driver = webdriver.Firefox(profile)
这些坑分别是:
有些地方只告诉你配置network.proxy.http和network.proxy.http_port。但是如果不设置network.proxy.type,一切都是浮云。这个配置是个整数,默认是0,就是直接连接;1就是手工配置代理。
profile.set_preference(‘network.proxy.type’, 1)
那个端口号3128是整数
profile.set_preference(‘network.proxy.http’, ‘proxy_url’)
profile.set_preference(‘network.proxy.http_port’, 3128)
如果有些资源是https的,是需要另外配置network.proxy.ssl和network.proxy.ssl_port的。例如facebook的图片。。。
set完以后,是需要update_preferences的。。。
profile.update_preferences()
最后贴一个完整的Firefox配置参数表:http://kb.mozillazine.org/Firefox_:_FAQs_:_About:config_Entries
如果发现自己的配置好像没有生效,那么在webdriver启动的Firefox里面输入about:config。然后对着上面那个配置参数表来看。总会发现掉哪个坑的。
转自http://magustest.com/2011/09/23/proxy-config-of-firefox-driver/
selenium firefox设置代理的更多相关文章
- python爬虫——selenium+firefox使用代理
本文中的知识点: python selenium库安装 firefox geckodriver的下载与安装 selenium+firefox使用代理 进阶学习 搭建开发环境: selenium库 fi ...
- Selenium/HtmlUnit设置代理获取JS生成的网页
通常我们使用Java提供的HttpURLConnection或者Apache的HttpClient获取的网页源代码都是直观可见的,其代码的内容和通过浏览器右键网页->点击查看网页源代码的内容一致 ...
- selenium phantomjs 设置代理ip方法
最近遇到phantomjs动态更换ip的功能,在知乎上看到一篇不错的文章,顺手记下来以备后用 phantomjs selenium 如何动态修改代理? 可以这样做(Python代码): # 不使用代理 ...
- CentOS7 设置代理
大多数公司的网络都使用局域网加代理上网,也就是说上外网必须使用公司指定的代理服务器,这有几个好处: 1. 首先代理可以一定程度提高浏览速度,因为可以将更多的网页缓存在代理服务器上,需要的时候直接拿就很 ...
- selenium设置代理,基于chrome浏览器
工作中遇到需要对项目中使用的selenium设置代理,跟大家分享一下. 1.下载chromeDriver:http://chromedriver.storage.googleapis.com/inde ...
- CentOS7设置系统/yum以及firefox web代理上网
一.系统全局的代理设置: 用vi/vim编辑器打开/etc/profile,追加如下内容: http_proxy=http://192.168.78.124:8080 ftp_proxy=http:/ ...
- python3 selenium模块Chrome设置代理ip的实现
python3 selenium模块Chrome设置代理ip的实现 selenium模块Chrome设置代理ip的实现代码: from selenium import webdriver chrome ...
- selenium设置Chrome浏览器不出现通知,设置代理IP
from selenium import webdriver PROXY = "" chrome_options = webdriver.ChromeOptions() prefs ...
- Python selenium + Firefox启动浏览器
Python selenium 的运用 from selenium import webdriver # from selenium.webdriver.firefox.firefox_profile ...
随机推荐
- 【Luogu】P3288方伯伯运椰子(消圈定理)
题目链接 分数规划题,详见luogu题解 #include<cstdio> #include<cstring> #include<cctype> #include& ...
- [bzoj] 3343 教主的魔法 || 带修改分块
原题 长度为n的序列,有两种操作: 1.[l,r]区间每个数+w 2.询问[l,r]区间有多少个数>c 记录lazy数组即可. #include<cstdio> #include&l ...
- 虚拟机——vmtools安装出现Detected GCC binary at usr.bin.gcc.
在安装VMWare Tools遇到过这样一个问题 Searching for GCC... Detected GCC binary at "/usr/bin/gcc". The p ...
- TCP面试题之四次挥手过程
TCP四次挥手过程: 1.第一次挥手:Client发送一个FIN,用来关闭Client到Server的数据传送,Client进入FIN_WAIT_1状态: 2.第二次挥手:Server收到FIN后,发 ...
- 1.tornado基础
import tornado.web ''' tornado基础web框架模块 ''' import tornado.ioloop ''' tornado的核心循环IO模块,封装了linux的epol ...
- 【linux高级程序设计】(第十四章)TCP高级应用 2
socket多路复用应用 int select (int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct time ...
- 【linux高级程序设计】(第十一章)System V进程间通信 4
共享内存 共享内存主要用于实现进程间大量数据传输. 共享内存的数据结构定义: 系统对共享内存的限制: 共享内存与管道的对比: 可以看到,共享内存的优势: 1.共享内存只需复制2次,而管道需要4次 2. ...
- Appium+python自动化8-Appium Python API【转载】
前言: Appium Python API全集,不知道哪个大神整理的,这里贴出来分享给大家. 1.contexts contexts(self): Returns the contexts withi ...
- python接口自动化9-https请求(SSL)【转载】
本篇转自博客:上海-悠悠 原文地址:http://www.cnblogs.com/yoyoketang/tag/python%E6%8E%A5%E5%8F%A3%E8%87%AA%E5%8A%A8%E ...
- mysql高可用架构之-MHA学习
此博文参考 博主:mysql高级DBA yayun 完成 简介: MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司 ...