Python urllib urlopen not working

后端 未结 8 1161
甜味超标
甜味超标 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:49

    This is what i use to get data from urls, its nice because you could save the file at the same time if you need it:

    import urllib
    
    result = urllib.urlretrieve("http://diveintopython.org/")
    
    print open(result[0]).read()
    

    output:

    ''
    

    Edit: urlretrieve works in python 2 and 3

提交回复
热议问题