Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #8628

Re: urllib, urlretrieve method, how to get headers?

References <BANLkTimLsFYV+OknfsOe=L3fidMBnecB-A@mail.gmail.com>
Date 2011-07-01 00:30 -0700
Subject Re: urllib, urlretrieve method, how to get headers?
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.537.1309505452.1164.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Jul 1, 2011 at 12:03 AM, Даниил Рыжков <daniil.re@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: urllib, urlretrieve method, how to get headers? Chris Rebert <clp2@rebertia.com> - 2011-07-01 00:30 -0700

csiph-web