SSLError:超过最大重试次数并出现 url 错误?如何解决这个问题?

4 python ssl ssl-certificate certifi

我正在尝试从网站上删除文本,并且我正在使用请求模块来执行此操作。

使用给定的代码(此处以 Facebook 为例)

requests.get('http://facebook.com')
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

SSLError: HTTPSConnectionPool(host='facebook.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])")))
Run Code Online (Sandbox Code Playgroud)

我尝试了以下方法但没有成功:

pip install certifi
pip install certifi_win32
Run Code Online (Sandbox Code Playgroud)

任何帮助将不胜感激!谢谢你!

小智 9

你可以尝试这个方法

import requests
from urllib3.exceptions import InsecureRequestWarning
from urllib3 import disable_warnings

disable_warnings(InsecureRequestWarning)

page = requests.get('http://facebook.com', verify=False)

print(page.content)
Run Code Online (Sandbox Code Playgroud)