Python+selenium爬虫报错 ERROR:ssl_client_socket_impl.cc(1098)] handshake failed

本文聚焦Python爬虫使用selenium时的报错问题。在用Chrome浏览器访问时出现ERROR:ssl_client_socket_impl.cc(1098)] handshake failed报错,给出解决方案,针对Chrome、Firefox、Internet Explorer三种浏览器分别介绍忽略证书错误的设置方法。
该文章已生成可运行项目,

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)
本文章已经生成可运行项目
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值