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


Groups > comp.lang.python > #3556

Re: Looking for a urllib(2) cookie handler

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!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.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'compiler': 0.07; 'recipe': 0.07; 'skip:` 10': 0.07; 'sqlite': 0.07; 'python': 0.07; 'am,': 0.14; 'received:74.125.82.44': 0.14; 'received:mail- ww0-f44.google.com': 0.14; 'wrote:': 0.14; '"import': 0.16; 'compiling,': 0.16; 'cookies': 0.16; 'firefox.': 0.16; 'sqlite3': 0.16; 'subject:urllib': 0.16; 'url:blog': 0.18; 'figure': 0.18; 'tue,': 0.20; 'cc:no real name:2**0': 0.20; 'cc:2**0': 0.20; 'cheers,': 0.20; 'header:In-Reply-To:1': 0.22; 'cc:addr:python- list': 0.22; 'carter': 0.23; "i'm": 0.26; 'chris': 0.27; 'google': 0.27; 'message-id:@mail.gmail.com': 0.28; 'cc:addr:python.org': 0.31; 'import': 0.32; 'requires': 0.35; 'there': 0.35; 'file': 0.35; 'think': 0.36; 'system.': 0.37; 'some': 0.37; 'url:python': 0.37; 'apr': 0.38; 'received:google.com': 0.38; 'where': 0.39; 'would': 0.40; 'header:Received:5': 0.40; 'simple': 0.60; '2011': 0.62; 'url:net': 0.62; '"just': 0.84; '(3rd': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=tQxAYe8ofArn8nUllF0zgQeBr/hd/QsGaBXuziQ/cOE=; b=dq+U2RdNBt/+acuOR/KZnlat84ZvzH7Y+HwwtEko6/U+cgYOrwRhpTFgrcD5v9wtsq Nm4g1YVX0wyDBG4qnpceq3yRvmJnbAOvYTy7RMuViPYtK+MR9xW0Qlt6S5TCrelERF6i 102Mcx5EXyp7vXR5nqkd+ADpJffUPtk9AuwD0=
DomainKey-Signature a=rsa-sha1; c=nofws; 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; b=Y3eBVKf9AAeeGMuUWWaVDO+LXXpmWuOHFIs/mJcmEDJfebBOpPWLHLOxf/JRi6DHgU 0FadEQ85HeI+cuX+vcv8d0O8Q59EgjxsbgLF3JMo7w7W7WT09Sy1Q3UwwDjzmpbeXX8N +9Q7fqgJkS/EF6Z632NlNMcWyibXYjW/zBAIE=
MIME-Version 1.0
Sender chris@rebertia.com
In-Reply-To <6acd452a-9bf5-4908-ba05-18a70174092b@j9g2000prj.googlegroups.com>
References <6acd452a-9bf5-4908-ba05-18a70174092b@j9g2000prj.googlegroups.com>
Date Tue, 19 Apr 2011 05:01:40 -0700
X-Google-Sender-Auth cjKNhnxVUP04r3vUfFCQTr7aov0
Subject Re: Looking for a urllib(2) cookie handler
From Chris Rebert <clp2@rebertia.com>
To Mark Carter <alt.mcarter@gmail.com>
Content-Type text/plain; charset=UTF-8
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.557.1303214501.9059.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 82.94.164.166
X-Trace 1303214501 news.xs4all.nl 32470 [::ffff:82.94.164.166]:53481
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:3556

Show key headers only | View raw


On Tue, Apr 19, 2011 at 4:44 AM, Mark Carter <alt.mcarter@gmail.com> wrote:
> I'm in python 2.6.5, and have Firefox 3.6.13. I would like to download
> some html from a site and scrape it programatically. The site requires
> a cookie, which I have in Firefox.
>
> Is there a simple python recipe I can use to read the contents of a
> url and say "just use the cookie that I have in Firefox"?

Untested (3rd Google hit for "import firefox cookies python"):
http://blog.mithis.net/archives/python/90-firefox3-cookies-in-python

At a minimum, I think you'll need to replace:
from pysqlite2 import dbapi2 as sqlite
With:
import sqlite3 as sqlite

You'll also have to figure out where Firefox's `cookies.sqlite` file
is located on your system.

Cheers,
Chris
--
My compiler is compiling, I swear!
http://blog.rebertia.com

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


Thread

Looking for a urllib(2) cookie handler Mark Carter <alt.mcarter@gmail.com> - 2011-04-19 04:44 -0700
  Re: Looking for a urllib(2) cookie handler Chris Rebert <clp2@rebertia.com> - 2011-04-19 05:01 -0700
  Re: Looking for a urllib(2) cookie handler Mark Carter <alt.mcarter@gmail.com> - 2011-04-19 05:48 -0700
    Re: Looking for a urllib(2) cookie handler Chris Rebert <clp2@rebertia.com> - 2011-04-19 05:57 -0700

csiph-web