无法在python中使用带有硒的http代理访问httpS网站

时间:2020-06-18 17:58:12

标签: python selenium selenium-chromedriver ssl-certificate

最近两天,我尝试使用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)

0 个答案:

没有答案