天天看點

selenium 您的連接配接不是私密連接配接的解決辦法

一、問題描述

  用selenium啟動浏覽器時,chrome提示您的連接配接不是私密連接配接。

selenium 您的連接配接不是私密連接配接的解決辦法

 二、解決方案

方案1:

在目前頁面用鍵盤輸入  thisisunsafe  ,不是在位址欄輸入,就直接敲鍵盤就行了,頁面即會自動重新整理進入網頁,親測有效。

但是有更簡單的方法,見方案2。

方案2:

(2)設定忽略ssl證書認證的錯誤,或者接收不信任的認證

  Chrome:

options.add_argument('ignore-certificate-errors')      
from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument('ignore-certificate-errors')

driver = webdriver.Chrome(chrome_options=options)
driver.get('https://cacert.org/')

driver.close()      

  Firefox:

profile.accept_untrusted_certs = True      
from selenium import webdriver

profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True

driver = webdriver.Firefox(firefox_profile=profile)
driver.get('https://cacert.org/')

driver.close()      

  IE:

capabilities['acceptSslCerts'] = True           
from selenium import webdriver

capabilities = webdriver.DesiredCapabilities().INTERNETEXPLORER
capabilities['acceptSslCerts'] = True

driver = webdriver.Ie(capabilities=capabilities)
driver.get('https://cacert.org/')

driver.close()      

  

Only action can relieve the uneasiness.