1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| #! /usr/bin/env python
import sys
sys.path.append("C:\\Documents and Settings\\Administrateur\\Bureau\\Projets\_Classes")
import scrape
def sqlite2cookie(filename):
from cStringIO import StringIO
from pysqlite2 import dbapi2 as sqlite
import cookielib
con = sqlite.connect(filename)
cur = con.cursor()
cur.execute("SELECT host, path, isSecure, expiry, name, value from moz_cookies WHERE host LIKE 'imacros.forum-libre.info'")
ftstr = ["FALSE","TRUE"]
s = StringIO()
s.write("""\
# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html
# This is a generated file! Do not edit.
""")
for item in cur.fetchall():
s.write("%s\t%s\t%s\t%s\t%s\t%s\t%s\n" % (
item[0], ftstr[item[0].startswith('.')], item[1],
ftstr[item[2]], item[3], item[4], item[5]))
s.seek(0)
cookie_jar = cookielib.MozillaCookieJar()
cookie_jar._really_load(s, '', True, True)
#print cookie_jar
return cookie_jar
mon_cookie = sqlite2cookie("C:\\Documents and Settings\\Administrateur\\Application Data\\Mozilla\\Firefox\\Profiles\\febeprof.stefane\\Copie de cookies.sqlite" |
Partager