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

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -