当我发送 HEAD 请求以expired.badssl.com测试脚本将如何响应时,我收到以下错误:
HTTPSConnectionPool(host='expired.badssl.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)'),))
我可以专门捕捉到,SSLError以便我知道这是一个糟糕的 SSL 吗?
我需要将此部分分配给except: CERTIFICATE_VERIFY_FAILEDfrom[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:852)
我的请求:
host = "https://expired.badssl.com/"
timeout = 5
try:
r = requests.head(host, headers=headers, timeout=timeout)
try:
print ('Status', r.status_code)
print ('Headers', r.headers)
except NameError:
print("Undefined variable")
except requests.exceptions.Timeout:
print ('Timeout...')
except requests.exceptions.TooManyRedirects:
print ('Bad URL...')
except requests.exceptions.RequestException as e:
print (e)
PIPIONE
芜湖不芜
相关分类