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?

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <chris@rebertia.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.023
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'everyone!': 0.05; 'subject:method': 0.09; 'am,': 0.13; 'wrote:': 0.15; 'subject:headers': 0.16; 'subject:urllib': 0.16; 'object,': 0.16; 'cc:addr:python-list': 0.16; 'cheers,': 0.19; 'cc:2**0': 0.21; 'cc:no real name:2**0': 0.22; 'header:In-Reply-To:1': 0.22; 'fri,': 0.28; 'message-id:@mail.gmail.com': 0.28; 'alternatives': 0.29; 'cc:addr:python.org': 0.30; 'subject:?': 0.31; 'chris': 0.32; 'headers': 0.32; 'there': 0.34; 'regular': 0.36; 'file': 0.36; 'using': 0.37; 'received:google.com': 0.38; 'subject:: ': 0.38; 'hello,': 0.38; 'received:74.125': 0.40; '12:03': 0.84; 'sender:addr:chris': 0.84; 'url:rebertia': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=JbM3U6VhQ+K1Kan6IBl81IsEWYCH/XeFnTjUd55DYUk=; b=SgTgLdLgOgB+YXWdTaT88fJkly94UtP/mp4hNfOdyL42gKmj7nJtbSPwluzh1UJ9yl Mg4u+26M1WcOy0l3qd6yXbjha+DckTaK5h6cH64Mp6sGzIiipv93MqxfoaUofLphbBBj uwDLxcLbQzZmEsQWwtIVKbj+85yR7hr/7Uh04=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <BANLkTimLsFYV+OknfsOe=L3fidMBnecB-A@mail.gmail.com>
References <BANLkTimLsFYV+OknfsOe=L3fidMBnecB-A@mail.gmail.com>
Date Fri, 1 Jul 2011 00:30:44 -0700
X-Google-Sender-Auth wps9b5F4jXVZ-uMRGQqQ4Xs-PNg
Subject Re: urllib, urlretrieve method, how to get headers?
From Chris Rebert <clp2@rebertia.com>
To Даниил Рыжков <daniil.re@gmail.com>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.537.1309505452.1164.python-list@python.org> (permalink)
Lines 15
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1309505452 news.xs4all.nl 21877 [2001:888:2000:d::a6]:34252
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:8628

Show key headers only | 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