SSLのURLで requests を使用すると、↓以下のようなエラーが出ることがありました。
requests.exceptions.SSLError: HTTPSConnectionPool(host='【URL】 ', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:833)'),))
↓こちらのサイトを参考に、try 〜 except で対処しました。
Python requestsのエラー処理 – SIer(業務系SE・PG)からWeb系への転職失敗反省録
try:
response=requests.get(url,headers=headers)
if response.status_code == requests.codes.ok:
print("wwwあり:response.status_code = 200 OK")
return True
except requests.exceptions.ConnectionError as e:
print("wwwあり:ConnectionErrorエラーです.取得可能性あり.")