HTTPSConnectionPool SSL错误证书验证失败 [英] HTTPSConnectionPool SSL Error certificate verify failed

查看:76
本文介绍了HTTPSConnectionPool SSL错误证书验证失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm working on web scraping some particular websites and therefor I use the python 3 requests package and beautifulsoup. While processing a test over some websites I got this error :

requests.exceptions.SSLError:HTTPSConnectionPool(host ='autoglassbodyrepair.lawshield.co.uk',port = 443):url超过最大重试次数:/(由SSLError(SSLError(错误的握手:错误([('SSL例程','tls_process_server_certificate','证书验证失败')],),,),))

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禁止并变成红色,以处理该页面.我想要的是,如果有一个不允许我访问该页面的异常,我将忽略它并转到下一页进行处理,但是如果没有异常,我将处理当前页面并忽略那些SSl证书.

When I try over my browser it shows me that the certificate is expired yet I can process to the page with https barred and turned to red. What I want is if there's an exception which won't allow me to access the page I'd just ignore it and get to the next page to process but if there's no exception I'd process the current page and ignore those SSl certificate.

在此先感谢您的帮助!

推荐答案

我明白了,它只需要忽略证书即可,如下面的代码所示,由于连接不安全,您会收到警告.

I got it, it just need to ignore the certificate as the code below, you would get a warning as insecure connection.

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

这篇关于HTTPSConnectionPool SSL错误证书验证失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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