Using Urllib Gives Ssl Error
Solution 1:
I had this issue not so long ago. Try giving the following commands a go:
- pip install requests[security]
If that doesn't work, try the following:
- pip install pyOpenSSL
- pip install cryptography
- pip install idna
Solution 2:
Try the requests module. I am using a windows, so try the mac equivalent of a pip install. With Python 3.6, I believe that urllib has been having some issues. If you are trying to webscrape, the requests module is better for Python 3, than the urllib module.
Below is an example from the other day when I was webscraping Wikipedia for stock tickers:
response = requests.get("https://en.wikipedia.org/wiki/List_of_S26P_500_companies")
soup = bs4.BeautifulSoup(response.text)
I got the url by using the requests module, and then was able to work with the text using beautiful soup. From what I gathered, urllib is to be avoided at all times for Python 3+ and is more suitable for Python 3. Try to do exactly what you're doing, but via the requests module instead of urllib.
Post a Comment for "Using Urllib Gives Ssl Error"