python dowload

ssteinerX@gmail.com ssteinerx at gmail.com
Tue Feb 23 21:22:39 CET 2010


On Feb 23, 2010, at 2:42 PM, monkeys paw wrote:

> I used the following code to download a PDF file, but the
> file was invalid after running the code, is there problem
> with the write operation?
> 
> import urllib2
> url = 'http://www.whirlpoolwaterheaters.com/downloads/6510413.pdf'
> a = open('adobe.pdf', 'w')

Try 'wb', just in case.

S



> for line in urllib2.urlopen(url):
>    a.write(line)
> -- 
> http://mail.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list