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

References <6acd452a-9bf5-4908-ba05-18a70174092b@j9g2000prj.googlegroups.com>
Date 2011-04-19 05:01 -0700
Subject Re: Looking for a urllib(2) cookie handler
From Chris Rebert <clp2@rebertia.com>
Newsgroups comp.lang.python
Message-ID <mailman.557.1303214501.9059.python-list@python.org> (permalink)

Show all headers | 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