有关于selenium+chrome proxy添加代理的坑
作者:互联网
selenium+chrome proxy添加代理的坑
最近一直在搞selenium+chrome 爬取google引擎数据,该方法chromeoptions.add_argument(f’–proxy-server=23.19.99.26:8800’)一直代理不上,搞的很头疼,翻阅了源代码,最后终于成功,特此记录爬坑过程!
直接上代码:
proxy = '23.19.99.26:8800'
desired_capabilities = webdriver.DesiredCapabilities.CHROME.copy()
desired_capabilities['proxy'] = {
"httpProxy": proxy,
"ftpProxy": proxy,
"sslProxy": proxy,
"noProxy": None,
"proxyType": "MANUAL",
"class": "org.openqa.selenium.Proxy",
"autodetect": False
}
browser = webdriver.Chrome(executable_path='E:\chromdriver\chromedriver', desired_capabilities=desired_capabilities, options=chromeoptions)
标签:chrome,selenium,capabilities,desired,proxy,99.26 来源: https://blog.csdn.net/weixin_40303822/article/details/121395533