Reputation: 1
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 urllib and continue to get an error about ssl certificate failure. I'm running on Jupyter notebook, Windows 10, and Python 3.7.
I tried pip installing certifi and urllib but those are already satisfied. I've tried restarting Jupyter and that does not fix the problem. I'm not really sure where to start to fix this as I'm not super familiar with urllib.
I expect this to download the images and output to the csv file, and it does output to the csv file, but the image won't download when I get this error:
The error doesn't halt the program but it does inhibit the intended function of the program.
Upvotes: 0
Views: 1413
Reputation: 4964
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.
Upvotes: 0
Reputation: 135
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()
Upvotes: 1