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 ...
随机推荐
- jmeter的build.xml
<?xml version="1.0"?><!-- Licensed to the Apache Software Foundation (ASF) unde ...
- [bzoj3514][CodeChef GERALD07] Chef ans Graph Queries [LCT+主席树]
题面 bzoj上的强制在线版本 思路 首先可以确定,这类联通块相关的询问问题,都可以$LCT$+可持久化记录解决 用LCT维护生成树作为算法基础 具体而言,从前往后按照边的编号顺序扫一遍边 如果这条边 ...
- [poj] 1236 networks of schools
原题 这是一道强连通分量板子题. 显然subtask1 是要输出入度为0的点的个数 而subtask2,我们考虑一下最优一定是把一个出度为零的点连到入度为零的点上,这样我们要输出的就是max(出度为零 ...
- Codeforces Round #324 (Div. 2) A
A. Olesya and Rodion time limit per test 1 second memory limit per test 256 megabytes input standard ...
- vue的main.js
import Vue from 'vue'; import App from './App.vue'; //================http 请求======================= ...
- js实时监听input中值得变化
<!DOCTYPE html> <html> <head> <title>zepto</title> <meta name=" ...
- 静态页面之间的转发与json与ajax做到动态数据
我们见过很多使用jsp ,php,asp的动态网页技术的网站了,我们知道如果一个网站内容更新频率极低,而内容量不是十分庞大时,这样的网站(一次开发完成后不会需要较多的维护成本)的完全可以使用全部使用静 ...
- hihoCoder 1015KMP
#include <iostream> #include <algorithm> #include <stdio.h> #include <math.h> ...
- 51nod1086 背包问题 V2——二进制优化
有N种物品,每种物品的数量为C1,C2......Cn.从中任选若干件放在容量为W的背包里,每种物品的体积为W1,W2......Wn(Wi为整数),与之相对应的价值为P1,P2......Pn(Pi ...
- Kubernetes监控工具
#镜像在谷歌上需要FQ#####################################监控工具#当前最新版本 heapster https://github.com/kubernetes/h ...