python dowload

Shashwat Anand anand.shashwat at gmail.com
Tue Feb 23 21:28:53 CET 2010


PyPdf/pdfminer library will be of help

On Wed, Feb 24, 2010 at 1:47 AM, Tim Chase <python.list at tim.thechases.com>wrote:

> 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')
>>
>
> Sure you don't need this to be 'wb' instead of 'w'?
>
>
>  for line in urllib2.urlopen(url):
>>     a.write(line)
>>
>
> I also don't know if this "for line...a.write(line)" loop is doing newline
> translation.  If it's a binary file, you should use .read() (perhaps with a
> modest-sized block-size, writing it in a loop if the file can end up being
> large.)
>
> -tkc
>
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100224/522d20a2/attachment.html>


More information about the Python-list mailing list