Need script to download file at known address

Alex Martelli aleaxit at yahoo.com
Wed Sep 15 17:20:43 CEST 2004


Radioactive Man <rm at rm.rm> wrote:

> I am fairly new to the latest verion of Python and using it on windows
> 95, 2000, and/or XP.  What libraries, modules, functions, etc. would I
> need to set up a Python script to download a file, say
> "htttp://www.sound.com/files/bob.wav" to my own hard drive at
> "c:\sound\bob.wav"?  

Something like:

import urllib
urllib.urlretrieve( "htttp://www.sound.com/files/bob.wav",
                           'c:/sound/bob.wav')

should be fine.

> I haven't found any good examples of such an operation in the
> documentation at the Python website.  Any suggestions are appreciated.

http://docs.python.org/lib/module-urllib.html has the docs of
urlretrieve, and it's SO simple that I don't really see what "good
examples" one might provide.  A book that by design is full of examples
(hopefully good) is the Python Cookbook, which in the intro to Chapter
10 (Network Programming) gives a slightly richer example which downloads
several files with urllib.urlretrieve.
http://www.python9.org/p9-zadka.ppt may have some useful pointers,
perhaps. 

http://www.experts-exchange.com/Programming/Programming_Languages/Python
/Q_21048439.html has exactly the same question you asked, but you have
to "sign up" to see the solution (always the same one).


Alex



More information about the Python-list mailing list