urllib, urlretrieve method, how to get headers?

Chris Rebert clp2 at rebertia.com
Fri Jul 1 03:30:44 EDT 2011


On Fri, Jul 1, 2011 at 12:03 AM, Даниил Рыжков <daniil.re at gmail.com> wrote:
> Hello, everyone!
>
> How can I get headers with urlretrieve? I want to send request and get
> headers with necessary information before I execute urlretrieve(). Or
> are there any alternatives for urlretrieve()?

You can use regular urlopen(), get the headers using the .info()
method of the resulting object, and do the file writing manually.

Cheers,
Chris
--
http://rebertia.com



More information about the Python-list mailing list