错误:ssl_client_socket_openssl.cc(1158)]与ChromeDriver Chrome浏览器和Selenium握手失败 [英] ERROR:ssl_client_socket_openssl.cc(1158)] handshake failed with ChromeDriver Chrome browser and Selenium

查看:1995
本文介绍了错误:ssl_client_socket_openssl.cc(1158)]与ChromeDriver Chrome浏览器和Selenium握手失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Chrome驱动程序中运行python selenium脚本时,即使一切正常,每次页面加载时,我都会收到以下大约三则错误消息.有没有办法抑制这些消息?

When running my python selenium script in Chrome driver I get about three of the below error messages every time a page loads even though everything works fine. Is there a way to suppress these messages?

[24412:18772:0617/090708:ERROR:ssl_client_socket_openssl.cc(1158)] 握手失败;返回-1,SSL错误代码1,net_error -100

[24412:18772:0617/090708:ERROR:ssl_client_socket_openssl.cc(1158)] handshake failed; returned -1, SSL error code 1, net_error -100

推荐答案

当浏览器要求您从网站接受证书时,会出现此错误.您可以设置默认情况下忽略这些错误,以免出现这些错误.

You get this error when the browser asks you to accept the certificate from the website. You can set to ignore these errors by default in order avoid these errors.

对于Chrome,您需要添加 -ignore-certificate-errors ,然后 -ignore-ssl-errors ChromeOptions()参数:

For Chrome, you need to add --ignore-certificate-errors and --ignore-ssl-errors ChromeOptions() argument:

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
driver = webdriver.Chrome(chrome_options=options)

对于Firefox,您需要将 accept_untrusted_certs FirefoxProfile()选项设置为True:

For the Firefox, you need to set accept_untrusted_certs FirefoxProfile() option to True:

profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
driver = webdriver.Firefox(firefox_profile=profile)

对于Internet Explorer,您需要设置 acceptSslCerts 所需的功能:

For the Internet Explorer, you need to set acceptSslCerts desired capability:

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

这篇关于错误:ssl_client_socket_openssl.cc(1158)]与ChromeDriver Chrome浏览器和Selenium握手失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆