使用硒3.8.1为Chrome设置代理的问题 [英] Problems with setting up proxy for chrome using selenium 3.8.1

查看:93
本文介绍了使用硒3.8.1为Chrome设置代理的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经像下面的代码那样在chrome上设置代理,但是当我更新到selenium 3.8.1代理停止工作时,我没有收到任何错误,只是不使用代理服务器,我也不知道为什么.我的chromedriver也是最新的.

I used to set up proxy on chrome like in a code below, but when i updated to selenium 3.8.1 proxy stops working, i dont get any errors it just doesn't use proxy server and i dont know why. My chromedriver is also up to date.

options = webdriver.ChromeOptions()
options.add_argument('--proxy-server=192.99.55.120:3128')
driver = webdriver.Chrome(executable_path='C:\chromedriver_win32\chromedriver.exe', chrome_options=options)
driver.get("http://google.com/")

想收到任何建议,也许是为chromedriver设置代理的另一种方法.

Would like to receive any advice, maybe alternative way to set up proxy for chromedriver.

推荐答案

如果仍然有人感兴趣,这就是我终于解决了问题的方法

If someone still interested, this is how i have finally solved the problem

from selenium.webdriver import Proxy
settings = {
        "httpProxy": "192.99.55.120:3128",
        "sslProxy": "192.99.55.120:3128"
    }
proxy = Proxy(settings)
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities.CHROME.copy()
cap['platform'] = "WINDOWS"
cap['version'] = "10"
proxy.add_to_capabilities(cap)

from selenium.webdriver.chrome.webdriver import WebDriver as ChromeDriver
driver = ChromeDriver(desired_capabilities=cap, executable_path='C:\chromedriver_win32\chromedriver.exe')

这篇关于使用硒3.8.1为Chrome设置代理的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆