赞
踩
最近在使用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)
....
最后在stackoverflow.com看到了有人通过创建Firefox配置文件最终解决的办法,最后尝试成功了,特意记录一下解决方法。
Firefox提示错误信息“Your connection is not secure…”(返回的错误码为NS_ERROR_NET_INADEQUATE_SECURITY),是因默认开启http2导致的,需要禁用http2。方法如下:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。