[Tutor] downloading remote files
Kent Johnson
kent37 at tds.net
Wed Oct 26 00:39:29 CEST 2005
Ed Hotchkiss wrote:
> is there a method in the stdlib of downloading a remote file via HTTP?
> or do i need sockets ...
for simple needs, you can use urllib:
import urllib
data = urllib.urlopen('http://www.google.com').read()
For more control, see urllib2. As suggested recently, Dive into Python has a good chapter on this which gives you several reasons why the above one-liner is a bad idea :-)
http://diveintopython.org/http_web_services/index.html
Kent
More information about the Tutor
mailing list