I am trying to get cookie (and rest of the page) from web site with cookie verification using
requests library, but it fails on SSL certificate verification:
HTTPSConnectionPool(host='***host***', port=443): Max retries exceeded with url: ***url*** (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1076)')))
I know (from here) that I can bypass it using verify=False
, but that is IMHO very unsecure way. I also know that there is a way get and parse certificates (from here), but this way is very much overkill for me. I should also note, that I have certifi installe by pip install certifi
, but it is not doing a thing from my POV.
Do you know how to fix this? Thx for answers!
My Code:
import requests
headers = {
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.76 Safari/537.36'
}
r = requests.get('https://secure.ulrichsw.cz/estrava/, headers=headers, verify=True)
session_id = r.cookies['PHPSESSID']
print(session_id)