最近两天,我尝试使用http代理在chrome中加载HTTPS网站,但没有成功。 这是我正在使用的代码:
options = webdriver.ChromeOptions()
options.add_argument('--allow-running-insecure-content')
options.add_argument('--ignore-certificate-errors')
capabilities = dict( DesiredCapabilities.CHROME )
proxy_address=proxy
proxy_port=port
print("Tested proxy: " + proxies[i])
i=i+1
if not "chromeOptions" in capabilities:
capabilities['chromeOptions'] = {
'args' : [],
'binary' : "",
'extensions' : [],
'prefs' : {}
}
capabilities['proxy'] = {
'httpProxy' : "%s:%i" %(proxy_address, proxy_port),
'ftpProxy' : "%s:%i" %(proxy_address, proxy_port),
'sslProxy' : "%s:%i" %(proxy_address, proxy_port),
'noProxy' : None,
'proxyType' : "MANUAL",
'class' : "org.openqa.selenium.Proxy",
'autodetect' : False
}
capabilities['acceptInsecureCerts'] = True
capabilities["acceptSslCerts"]=True
driver=webdriver.Chrome(options=options,desired_capabilities=capabilities,executable_path=path)