Python urllib urlopen not working

后端 未结 8 1094
甜味超标
甜味超标 2021-01-04 07:29

I am just trying to fetch data from a live web by using the urllib module, so I wrote a simple example

Here is my code:

import urllib

sock = urllib         


        
8条回答
  •  时光说笑
    2021-01-04 07:38

    I just queried the same question which is now over 5 years old.

    Please note that the URL given is also old, so i substituted the python welcome page.

    We can use the requests module in python 3.

    I use python 3 and the solution is below:

    import requests
    
    r = requests.get('https://www.python.org/')
    t = r.text
    
    print(t)
    

    This works and is clean.

提交回复
热议问题