export_firefox_cookies.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:jabbapylib3 作者: jabbalaci 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号