August 22nd, 2004, 01:44 PM
Problem with download use urllib
I have a problem when use urllib to download something from web.
the code looks like this:
the downloaded xxx.pdf is always little bigger than the original pdf if I download by click on the link.
and xxx.pdf can not be opened by acrobat reader, anyone know why this is happening?
August 22nd, 2004, 08:31 PM
I'd have to go with that the file hasn't been opened in write mode, or write-binary which you should probably be using here since as far as i know PDFs are binary files:
Note: you should use file() instead of open() in new programs .
sock = urllib.urlopen('whatever/some.pdf')
out = file('some.pdf', 'wb')
Hope this helps,
August 22nd, 2004, 10:38 PM
thanks a lot, that works.