Need script to download file at known address

Pierre Fortin pfortin at pfortin.com
Wed Sep 15 02:57:06 CEST 2004


On Wed, 15 Sep 2004 00:00:21 GMT Radioactive 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"?  
> 
> I haven't found any good examples of such an operation in the
> documentation at the Python website.  Any suggestions are appreciated.
> Thanks.


See:  11. Internet Protocols and Support
at http://python.org/doc/2.3.4/lib/lib.html

In this example, Yahoo uses 00=Jan, so 08=Sep...

>>> from urllib import urlopen
>>> URL1 = "http://ichart.finance.yahoo.com/table.csv?"
>>> URL2 = "s=IBM&a=08&b=14&c=2004&d=08&e=14&f=2004&g=d&ignore=.csv"
>>> urlopen("%s%s" % (URL1,URL2)).readlines()
['Date,Open,High,Low,Close,Volume,Adj. Close*\n',
'14-Sep-04,86.60,86.88,86.15,86.72,3953500,86.72\n', '<!--
ichart9.finance.dcn.yahoo.com uncompressed Tue Sep 14 17:55:33 PDT 2004
-->\n']
>>>



More information about the Python-list mailing list