Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #12057
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <crebert@ucsd.edu> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'url:sourceforge': 0.02; 'string.': 0.04; 'subject:module': 0.04; 'instance': 0.05; 'instance,': 0.05; 'function,': 0.07; 'mechanize': 0.07; 'python': 0.08; 'users,': 0.13; 'stringio': 0.16; 'subject:instance': 0.16; 'url:mechanize': 0.16; 'url:wwwsearch': 0.16; 'cc:addr:python- list': 0.16; 'mon,': 0.16; 'this:': 0.16; 'wrote:': 0.16; 'subject:Help': 0.17; 'cheers,': 0.18; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.22; 'header:In-Reply-To:1': 0.22; "shouldn't": 0.23; 'pm,': 0.24; 'aug': 0.24; 'code': 0.25; 'skip:b 20': 0.26; 'import': 0.28; 'message-id:@mail.gmail.com': 0.29; 'cc:addr:python.org': 0.30; 'module': 0.30; '22,': 0.30; 'chris': 0.32; 'list': 0.32; 'necessary.': 0.32; 'source': 0.33; 'it?': 0.33; 'received:132': 0.34; 'list.': 0.35; 'thank': 0.35; 'question': 0.36; 'doing': 0.36; 'but': 0.37; 'open': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'empty': 0.39; 'url:net': 0.60; 'you.': 0.62; 'believe': 0.65; 'therefore,': 0.66; 'url:example': 0.84; 'received:209.85.218.46': 0.91; 'received:mail- yi0-f46.google.com': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=simple/simple; d=ucsd.edu; i=crebert@ucsd.edu; q=dns/txt; s=041709-iport; t=1314059311; x=1345595311; h=mime-version:in-reply-to:references:date:message-id: subject:from:to:cc:content-transfer-encoding; z=MIME-Version:=201.0|In-Reply-To:=20<8199DBA0-5A00-4932-9 B7C-A5BAD8EC6EEA@mssm.edu>|References:=20<8199DBA0-5A00-4 932-9B7C-A5BAD8EC6EEA@mssm.edu>|Date:=20Mon,=2022=20Aug =202011=2017:27:18=20-0700|Message-ID:=20<CAMZYqRSpxpkD26 isu+BViJ=3D6aTq5A+J85CjAfAyz8ZtDbtaeDg@mail.gmail.com> |Subject:=20Re:=20Help=20on=20instance=20of=20closeable_r esponse=20in=20module=20Mechanize|From:=20Chris=20Rebert =20<crebert@ucsd.edu>|To:=20Yingjie=20Lin=20<Yingjie.Lin@ mssm.edu>|Cc:=20python-list@python.org |Content-Transfer-Encoding:=20quoted-printable; bh=nzKDW2y+jimuBYIprMheKeN+/0MHlxiLSRx4gytDo+U=; b=EHH/3LtleocFSWrYGYnKmwAFyHiVY40s6R1CcibBX64ltzCsmNAEjNwH m5SBdc1G1Hs+rNZ5EkWOCxPZQCYd424PSX/dhfxgBNH5oQDC3i7FcEORE QAS46I7hBvaj7dYTQLZi+PaObLPNPepkMPZr+f5fgV28lF9ltccI9KgHe E=; |
| X-IronPort-Anti-Spam-Filtered | true |
| X-IronPort-Anti-Spam-Result | AgEFAAjzUk6E7/kU/2dsb2JhbABBDoQ9o08Id4FAAQEBAQMSAg9WEAkCCw0CAiYCAiISAQUBHAYTIodTl2AKi3mIcYh/gSyEDIEQBIdgizaEfYM/hB48gytY |
| X-IronPort-AV | E=Sophos;i="4.68,266,1312182000"; d="scan'208";a="587858019" |
| X-Spam-Status | No |
| X-Spam-Level | |
| MIME-Version | 1.0 |
| In-Reply-To | <8199DBA0-5A00-4932-9B7C-A5BAD8EC6EEA@mssm.edu> |
| References | <8199DBA0-5A00-4932-9B7C-A5BAD8EC6EEA@mssm.edu> |
| Date | Mon, 22 Aug 2011 17:27:18 -0700 |
| Subject | Re: Help on instance of closeable_response in module Mechanize |
| From | Chris Rebert <crebert@ucsd.edu> |
| To | Yingjie Lin <Yingjie.Lin@mssm.edu> |
| 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.334.1314059312.27778.python-list@python.org> (permalink) |
| Lines | 43 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1314059312 news.xs4all.nl 23979 [2001:888:2000:d::a6]:34700 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:12057 |
Show key headers only | View raw
On Mon, Aug 22, 2011 at 5:17 PM, Yingjie Lin <Yingjie.Lin@mssm.edu> wrote: > Hi Python users, > > I have a question about the instance of closeable_response in module Mechanize. > > from mechanize import ParseResponse, urlopen > url = "http://wwwsearch.sourceforge.net/mechanize/example.html" > r = urlopen(url) > forms = ParseResponse(r, backwards_compat=False) > html_lines = r.read() > > If I call ParseResponse() before r.read(), then lforms would be a list containing one form > instance, and html_lines would be an empty string. If I call r.read() first, then html_lines > would be the HTML source code of the page, but forms would be an empty list. > > Therefore, I have to open the url twice, once for each function, like this: > > r = urlopen(url) > forms = ParseResponse(r, backwards_compat=False) > r = urlopen(url) > html_lines = r.read() > > I believe this shouldn't be necessary. What is the proper way of doing it? Thank you. Untested speculation: from StringIO import StringIO r = urlopen(url) html = r.read() s = StringIO(html) forms = ParseResponse(s, backwards_compat=False) Cheers, Chris
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Help on instance of closeable_response in module Mechanize Chris Rebert <crebert@ucsd.edu> - 2011-08-22 17:27 -0700
csiph-web