Looking for a urllib(2) cookie handler

Chris Rebert clp2 at rebertia.com
Tue Apr 19 14:01:40 CEST 2011


On Tue, Apr 19, 2011 at 4:44 AM, Mark Carter <alt.mcarter at 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



More information about the Python-list mailing list