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

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

问题描述

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

When running my python selenium script with 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 a 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天全站免登陆