gpt4 book ai didi

python - HTTPSConnectionPool SSL错误证书验证失败

转载 作者:行者123 更新时间:2023-12-03 08:21:21 25 4
gpt4 key购买 nike

我正在网上抓取某些特定的网站,因此我使用python 3请求包和beautifulsoup。在某些网站上处理测试时,出现此错误:

requests.exceptions.SSLError: HTTPSConnectionPool(host='autoglassbodyrepair.lawshield.co.uk', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')],)",),))




import requests as rq
import bs4

current_url = 'autoglassbodyrepair.lawshield.co.uk'
try:
req = rq.get(current_url)
except rq.exceptions.RequestException as e:
print(e)
else:
soup = bs4.BeautifulSoup(r.content, "html.parser")
text = soup.findAll(text = True)


当我尝试浏览器时,它显示证书已过期,但是我可以将https禁止并变成红色,以处理该页面。
我想要的是,如果有一个不允许我访问该页面的异常,我将忽略它并转到下一页进行处理,但是如果没有异常(exception),我将处理当前页面并忽略那些SSl证书。

在此先感谢您的帮助 !

最佳答案

我知道了,它只需要忽略以下代码中的证书,您将收到警告,因为连接不安全。

req = rq.get(current_url, verify = False)

关于python - HTTPSConnectionPool SSL错误证书验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55746814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com