Need script to download file at known address

Andrew Durdin adurdin at gmail.com
Thu Sep 16 22:08:36 EDT 2004


On Fri, 17 Sep 2004 01:46:42 GMT, Radioactive Man <rm at rm.rm> wrote:
> Here is the test script I came up with:
> 
> import urllib
> f =  urllib.urlopen("http://www.python.org/pics/pythonHi.gif")
> g = f.read()
> file = open("trash.gif", "w")
> file.write(g)
> file.close()

You're opening the output file in ascii mode, so newlines characters
are getting converted to the CR/LF combination. Change the second
parameter to open() to "wb".



More information about the Python-list mailing list