请求库的问题

时间:2020-12-23 17:38:26

标签: python-3.x ssl python-requests

我的代码返回一条错误消息,但我不知道为什么,我之前已经多次执行相同的逻辑,但从未发生过这样的事情,代码如下:

import requests
from bs4 import BeautifulSoup

site = 'https://www.fea.usp.br/internacional/universidades-conveniadas?pais=All'
req = requests.get(site)

错误信息:

- SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)
- MaxRetryError: HTTPSConnectionPool(host='www.fea.usp.br', port=443): Max retries exceeded with url: /internacional/universidades-conveniadas?pais=All (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))
- SSLError: HTTPSConnectionPool(host='www.fea.usp.br', port=443): Max retries exceeded with url: /internacional/universidades-conveniadas?pais=All (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1108)')))

1 个答案:

答案 0 :(得分:0)

网站的 SSL 证书可能已过期,您可以通过以下方式提出请求来绕过它:

req = request.get(site, verify=False)

这会产生警告,但您可以suppress