How To Fix A SSL Certificate Error With Urllib?
I'm developing a python program to grab all images from a website and download them to a folder along with creating a csv file to store all of this information. I'm utilizing urlli
Solution 1:
If you are using urllib
library use context parameter when you gave request to open URL. Here is implementation:
import urllib.request
import ssl
#Ignore SSL certificate errors
ssl_context = ssl.create_default_context()
ssl_context.check_hostname = False
ssl_context.verify_mode = ssl.CERT_NONE
html = urllib.request.urlopen(url, context=ssl_context).read()
Solution 2:
If you are able to consider using the requests
library instead of urllib
, you just do
import requests
response = requests.get('your_url', verify=False)
But also consider the warning here.
Post a Comment for "How To Fix A SSL Certificate Error With Urllib?"