I'm getting the following error while using request package in Python.
'[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1123)
I'm trying to access a link using the following code:
content = requests.get(link, verify=True, headers={"User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 12871.102.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"})
I searched for some solutions and found a few that talked about Install Certificate.command, but I can't find the file in my Python directory. I'm using Python 3.8. Any suggestion on how to get this resolved?
1 Answer 1
I had to provide the certificate to prevent this error from occuring.
cert = requests.certs.where()
page = requests.get(link,
verify=cert,
headers={"User-Agent": "Mozilla/5.0 (X11; CrOS x86_64 12871.102.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"})
This worked for me
answered Oct 4, 2020 at 21:09
Kuni
8652 gold badges10 silver badges32 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py