使用selenium 3.8.1为chrome设置代理的问题

gjmwrych  于 2023-08-01  发布在  Go
关注(0)|答案(3)|浏览(108)

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

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。

5f0d552i

5f0d552i1#

如果有人仍然感兴趣,这是我如何终于解决了这个问题

from selenium.webdriver import Proxy
from selenium.webdriver.chrome.webdriver import WebDriver as ChromeDriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities

settings = {
        "httpProxy": "192.99.55.120:3128",
        "sslProxy": "192.99.55.120:3128"
    }
proxy = Proxy(settings)

cap = DesiredCapabilities.CHROME.copy()
cap['platform'] = "WINDOWS"
cap['version'] = "10"
proxy.add_to_capabilities(cap)

driver = ChromeDriver(desired_capabilities=cap, executable_path='C:\chromedriver_win32\chromedriver.exe')

字符串

ulmd4ohb

ulmd4ohb2#

尝试

options.add_argument('--proxy-server="http=192.99.55.120:3128;https=192.99.55.120:3128"')

字符串
我也可以直接用这些参数运行你的chrome二进制文件,看看它是否能正常工作

chrome.exe --proxy-server="http=192.99.55.120:3128"

rm5edbpk

rm5edbpk3#

如果导航器询问代理的凭据用户名和密码,您需要处理此问题:(仅当警报出现时)

driver.get("http://username:password@google.com/")

字符串

相关问题