我正在尝试在selenium中为chrome驱动程序设置代理。 我已经看到很多答案,尝试了大部分。没有人为我工作。
Selenium版本2.53.2
capabilities = webdriver.DesiredCapabilities.CHROME
options = ChromeOptions()
options.add_argument('--proxy-server=http://%s' % proxy)
options.add_argument("start-maximized")
capabilities.setCapability("chrome.binary", "/Users/MacX/Downloads/chromedriver")
capabilities.setCapability(ChromeOptions.CAPABILITY, options)
browser = webdriver.Chrome(desired_capabilities=capabilities)
browser.get(url)
代理是
PROXY1 = "111.98.9.54:8080"
proxy = Proxy({
'proxyType': ProxyType.MANUAL,
'httpProxy': PROXY1,
'ftpProxy': PROXY1,
'sslProxy': PROXY1,
'noProxy': None
})
我收到此错误
capabilities.setCapability(ChromeOptions.CAPABILITY, options)
AttributeError: 'dict' object has no attribute 'setCapability'