August 22nd, 2004, 02: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, 09: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, 11:38 PM
thanks a lot, that works.