How to use urllib in python 3 ? 4 -
i using anaconda , python 3 - wrote below not working reason. new python please ! thank you.
import urllib.request x = urllib.request.urlopen('https://www.google.com') print(x.read())
you need ssl.sslcontext() , assuming have proper ca certs installed, can either create 1 directly or use ssl.create_default_context(...), e.g.:
>>> import ssl >>> resp = urllib.request.urlopen('https://www.google.com', context=ssl.sslcontext()) >>> resp.status 200 alternatively, use higher level library requests
Comments
Post a Comment