问题:1020: InsecureRequestWarning: Unverified HTTPS request is being made to host 'www.baidu.com'. Adding certificate verification is strongly advised.
requests.exceptions.SSLError: HTTPSConnectionPool(host='120.21.25.21', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate (_ssl.c:1056)')))
解决:
import requests from requests import session s = session() # 关闭SSL证书验证 # 进行弹出警告信息 requests.packages.urllib3.disable_warnings() r = s.get("https://www.baidu.com",verify=False) print(r.text)