Python爬虫报错 ERROR:ssl_client_socket_impl.cc(1098)] handshake failed的解决方法
最近在用selenium写爬虫,使用的浏览器是Chrome浏览器,当访问浏览器时出现了以下报错信息:

解决方案:
浏览器要求您接受网站的证书。您可以设置默认情况下忽略这些错误,以免发生这些错误。
1、对于Chrome,您需要添加 -ignore-certificate-errors 和-ignore-ssl-errors ChromeOptions()参数:
options = webdriver.ChromeOptions()
options.add_argument('-ignore-certificate-errors')
options.add_argument('-ignore -ssl-errors')
driver = webdriver.Chrome(chrome_options = options)
2、对于Firefox,您需要将 accept_untrusted_certs 设置为True:
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
driver = webdriver.Firefox(firefox_profile = profile)
3、对于Internet Explorer,您需要设置 acceptSslCerts 所需的功能:
caps = webdriver.DesiredCapabilities.INTERNETEXPLORER
caps['acceptInsecureCerts'] = True
caps['acceptSslCerts'] = True
driver = webdriver.Ie(capabilities = capabilities)
本文聚焦Python爬虫使用selenium时的报错问题。在用Chrome浏览器访问时出现ERROR:ssl_client_socket_impl.cc(1098)] handshake failed报错,给出解决方案,针对Chrome、Firefox、Internet Explorer三种浏览器分别介绍忽略证书错误的设置方法。
2619

被折叠的 条评论
为什么被折叠?



