Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #8639
| References | <mailman.536.1309503827.1164.python-list@python.org> <iujtq4$srp$1@solani.org> <BANLkTinNLdfVRt+ExwFaMzM=JAcrJ4NqKQ@mail.gmail.com> <BANLkTi=PeQd_9W1nY4aTpp5gN4sLEWWisQ@mail.gmail.com> <BANLkTinwir_KKhmq1EdQGWLvxLQ4v3CULQ@mail.gmail.com> |
|---|---|
| From | Kushal Kumaran <kushal.kumaran+python@gmail.com> |
| Date | 2011-07-01 22:31 +0530 |
| Subject | Re: urllib, urlretrieve method, how to get headers? |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.544.1309539723.1164.python-list@python.org> (permalink) |
On Fri, Jul 1, 2011 at 2:23 PM, Даниил Рыжков <daniil.re@gmail.com> wrote:
> Hello again!
> Another question: urlopen() reads full file's content, but how can I
> get page by small parts?
>
Set the Range header for HTTP requests. The format is specified here:
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35. Note
that web servers are not *required* to support this header.
In [10]: req = urllib2.Request('http://cdimage.debian.org/debian-cd/6.0.2.1/amd64/iso-cd/debian-6.0.2.1-amd64-CD-1.iso',
headers = { 'Range' : 'bytes=0-499' })
In [11]: f = urllib2.urlopen(req)
In [12]: data = f.read()
In [13]: len(data)
Out[13]: 500
In [14]: print f.headers
Date: Fri, 01 Jul 2011 16:59:39 GMT
Server: Apache/2.2.14 (Unix)
Last-Modified: Sun, 26 Jun 2011 16:54:45 GMT
ETag: "ebff2f-28700000-4a6a04ab27f10"
Accept-Ranges: bytes
Content-Length: 500
Age: 225
Content-Range: bytes 0-499/678428672
Connection: close
Content-Type: application/octet-stream
--
regards,
kushal
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
urllib, urlretrieve method, how to get headers? Даниил Рыжков <daniil.re@gmail.com> - 2011-07-01 18:03 +1100
Re: urllib, urlretrieve method, how to get headers? Peter Otten <__peter__@web.de> - 2011-07-01 09:43 +0200
Re: urllib, urlretrieve method, how to get headers? Даниил Рыжков <daniil.re@gmail.com> - 2011-07-01 19:26 +1100
Re: urllib, urlretrieve method, how to get headers? Даниил Рыжков <daniil.re@gmail.com> - 2011-07-01 19:53 +1100
Re: urllib, urlretrieve method, how to get headers? Kushal Kumaran <kushal.kumaran+python@gmail.com> - 2011-07-01 22:31 +0530
Re: urllib, urlretrieve method, how to get headers? Chris Rebert <clp2@rebertia.com> - 2011-07-01 10:02 -0700
Re: urllib, urlretrieve method, how to get headers? Даниил Рыжков <daniil.re@gmail.com> - 2011-07-02 11:47 +1100
csiph-web