def get_cookies_in_cookiejar(host):
"""Export cookies and put them in a cookiejar.
Return value: a cookiejar filled with cookies."""
# based on http://www.guyrutenberg.com/2010/11/27/building-cookiejar-out-of-firefoxs-cookies-sqlite/
cj = LWPCookieJar() # This is a subclass of FileCookieJar that has useful load and save methods
cookie_db = get_cookie_db_path(str(FIREFOX_DIR))
conn = db.connect(cookie_db)
cursor = conn.cursor()
sql = "SELECT {c} FROM moz_cookies WHERE host LIKE '%{h}%'".format(c=CONTENTS, h=host)
cursor.execute(sql)
for item in cursor.fetchall():
c = Cookie(0, item[4], item[5],
None, False,
item[0], item[0].startswith('.'), item[0].startswith('.'),
item[1], False,
item[2],
item[3], item[3]=="",
None, None, {})
#print c
cj.set_cookie(c)
return cj
评论列表
文章目录