Python3.x:chrome运行webdriver脚本提示--ignore-certificate-errors

1,分析原因:

 Python3.x:chrome运行webdriver脚本提示--ignore-certificate-errors

 根本原因是Chromedriver和Chrome的版本不兼容;

 网上很多方案说加上如下代码可以解决,但是我试过了Chromedriver和Chrome的版本不兼容加上这段代码一样解决不了,兼容了不用这段代码也可以正常显示:

from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches",["ignore-certificate-errors"])
options.add_argument('test-type')
browser = webdriver.Chrome(chrome_options=options)

2,解决方案:

 chromedriver下载地址:http://chromedriver.storage.googleapis.com/index.html

 chromedriver与chrome的对应关系表:

Python3.x:chrome运行webdriver脚本提示--ignore-certificate-errors

 3,python3.x实例代码:

from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches",["ignore-certificate-errors"])
options.add_argument('test-type')
browser = webdriver.Chrome(chrome_options=options)

#driver = webdriver.Chrome()
browser.get("http://www.baidu.com")

print('success')

 或者

from selenium import webdriver

browser = webdriver.Chrome()
browser.get("http://www.baidu.com")

print('success')

 以上两种方式都可以实现;

4,结果:

Python3.x:chrome运行webdriver脚本提示--ignore-certificate-errors

 测试版本供参考:chromedriver v2.34与chrome v61

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-09
猜你喜欢
  • 2022-01-16
  • 2021-09-20
  • 2022-12-23
  • 2021-03-30
  • 2022-12-23
  • 2022-12-23
  • 2021-11-15
相关资源
相似解决方案