Why can't I get Python's urlopen() method to work on Windows?

前端 未结 4 1484
一生所求
一生所求 2020-12-04 02:16

Why isn\'t this simple Python code working?

import urllib
file = urllib.urlopen(\'http://www.google.com\')
print file.read()

This is the er

4条回答
  •  鱼传尺愫
    2020-12-04 02:38

    for python 3:

    import urllib.request
    
    proxies=urllib.request.ProxyHandler({'http':None})
    
    opener=urllib.request.build_opener(proxies)
    
    urllib.request.install_opener(opener)
    
    j=urllib.request.urlopen(url="https://google.com")
    
    k=j.read()
    
    print(k)
    

提交回复
热议问题