当前位置:   article > 正文

Selenium Firefox webdriver无法抓取证书不合格的HTTPS网站解决办法_火狐浏览器无法获取网站证书怎么回事

火狐浏览器无法获取网站证书怎么回事

最近在使用Selenium Firefox webdriver抓取网页内容,在抓取一些证书不合格的HTTPS网站时,Firefox经常报错,并提示“Your connection is not secure…”的错误提示,返回的错误码为NS_ERROR_NET_INADEQUATE_SECURITY。其中使用的版本如下:

Selenium: 3.14
Python: 3.6
Firefox: 60.6.1

几乎百度、Google了所有的资料,发现通过设置变量accept_insecure_certs、accept_untrusted_certs 的解决方案根本不生效。

options = webdriver.FirefoxOptions()
options.accept_insecure_certs = True

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

browser = webdriver.Firefox(firefox_options=options, firefox_profile=profile)
....
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

最后在stackoverflow.com看到了有人通过创建Firefox配置文件最终解决的办法,最后尝试成功了,特意记录一下解决方法。

一、创建Firefox配置文件

Firefox提示错误信息“Your connection is not secure…”(返回的错误码为NS_ERROR_NET_INADEQUATE_SECURITY),是因默认开启http2导致的,需要禁用http2。方法如下:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/624505
推荐阅读
相关标签
  

闽ICP备14008679号