Gr1*_*ity 4 python proxy google-chrome selenium-webdriver
我曾经在 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/")
Run Code Online (Sandbox Code Playgroud)
希望收到任何建议,也许是为 chromedriver 设置代理的替代方法。
如果有人仍然感兴趣,这就是我最终解决问题的方式
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')
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5644 次 |
| 最近记录: |