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


Groups > comp.lang.python > #75094

Re: how to download special range content with requests in python?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.052
X-Spam-Evidence '*H*': 0.90; '*S*': 0.00; 'preferably': 0.05; 'http': 0.09; 'cc:addr:python-list': 0.11; '23,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'method;': 0.16; 'read()': 0.16; 'subject:download': 0.16; 'subject:requests': 0.16; 'url:debian': 0.16; 'url:iso': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; 'import': 0.22; 'cc:addr:python.org': 0.22; 'sends': 0.24; 'cc:2**0': 0.24; 'url:edu': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'requests': 0.31; 'request,': 0.31; 'level.': 0.33; 'subject:with': 0.35; 'case,': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'server': 0.38; 'pm,': 0.38; 'explain': 0.39; 'read': 0.60; 'range': 0.61; "you're": 0.61; 'you.': 0.62; 'happen': 0.63; 'talking': 0.65; 'url:0': 0.67; 'incorporate': 0.68; 'skip:r 30': 0.69; 'further,': 0.74; 'jul': 0.74; 'special': 0.74; 'ball,': 0.84; '\xe2\x80\x8d': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=DCfgdemAqCSq2mECjTwbvZAc6gRCz4jFjLHhNlw+K6k=; b=ey5uPsFBtuAncDW/eXvJoWBuzA93uSJKl9NPgHpfT6zYVInGZ49LiEsLcWcuKRpkKk T5z/xyW4wbZiY0F7EIaKrlRK4R+9zZd+8Wm0+aQ4/HpZryGVV3eAC2SjgQUcesWAKJQh RHK8zhAF8f/RpNVvaOp1X8O1eA2a5iNNUDVPfSbko1NgDmUPgCRtBp8pwyEiDKLSZzjf zIJTWm7A8k3CTQE9xfgl8gx8d8zXSZ070q/37sScdypEOiR4etG+N7mrHQG7NeHl9JOP u/Q2hL0Ggo6RQ7LEOf+YIflmiceFOO33sE1K55glu+9rBNAjLxNWy88KeOpkXmlnO/Jk lErg==
MIME-Version 1.0
X-Received by 10.220.81.194 with SMTP id y2mr3382170vck.29.1406131135433; Wed, 23 Jul 2014 08:58:55 -0700 (PDT)
In-Reply-To <tencent_11DB8BA910751CAB361D6B09@qq.com>
References <tencent_11DB8BA910751CAB361D6B09@qq.com>
Date Thu, 24 Jul 2014 01:58:55 +1000
Subject Re: how to download special range content with requests in python?
From Chris Angelico <rosuav@gmail.com>
Cc python-list <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.12246.1406131138.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1406131138 news.xs4all.nl 2948 [2001:888:2000:d::a6]:45680
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:75094

Show key headers only | View raw


On Wed, Jul 23, 2014 at 7:44 PM, 水静流深 <1248283536@qq.com> wrote:
> url='http://debian.cites.illinois.edu/pub/debian-cd/7.6.0/amd64/iso-cd/debian-7.6.0-amd64-CD-1.iso'
> import requests
> r = requests.get(url).read(0,1000)  ‍
>
> why i can not download special range(from 0 to 10000)  content with requests
> in python‍?

Looking into my crystal ball, I think you're trying to have this send
the Range header. If that's the case, then there's no way you can do
that with the read() method; you have to incorporate that into the
original request, and then just read everything the server sends you.

If that's not what you're talking about, please explain further,
preferably demonstrating what you want to happen at the HTTP level.

ChrisA

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


Thread

Re: how to download special range content with requests in python? Chris Angelico <rosuav@gmail.com> - 2014-07-24 01:58 +1000

csiph-web