【问题标题】:Importing Firefox cookies into python from text file将 Firefox cookie 从文本文件导入 python
【发布时间】:2015-09-29 13:41:17
【问题描述】:

我正在尝试将 cookie 加载到 python 请求模块中。使用 FF 扩展“高级 cookie 管理器”(https://www.facebook.com/cookiemanager),我将 cookie 从 Firefox 导出到一个文本文件,如下所示:

.xxx.net    TRUE    /   FALSE   1435176898  _gat    1
.xxx.net    TRUE    /   FALSE   1498248358  _ga GA1.2.749243760.1435176299
.YYY.com    TRUE    /   FALSE   1488730321  _ga GA1.2.630339061.1425658321
.YYY.com    TRUE    /   FALSE   1472993710  __qca   P0-913150413-1425658321107
.YYY.com    TRUE    /   FALSE   1488730321  __gads  ID=8edab7af1673d945:T=1425658321:S=ALNI_Ma6b9RCM4Cm7IGSojNoWU5DohhJ0w
www.YYY.com FALSE   /   FALSE   1457194477  htg_subform_hide    1

我遇到过How to send cookies in a post request with the Python Requests library?,但公认的例子:

cookie = {'enwiki_session': '17ab96bd8ffbe8ca58a78657a918558'}

仅指一个字段。在我的文件中导出的每条记录都有 7 个字段,我假设其中一些是

domain , path , expires, Name

将这些 cookie 导入 python 以便我可以在请求中使用它们的最佳方法是什么?

【问题讨论】:

    标签: python firefox cookies


    【解决方案1】:

    Advance Cookie Manager 将 cookie 导出为以下格式的文本文件:

    HOST isDomainCookie PATH IsSecure EXPIRY NAME VALUE

    注意:TAB 是字段之间的分隔符

    【讨论】:

    • 能否请您更详细地描述您的答案并正确格式化您的代码。
    猜你喜欢
    • 2018-09-05
    • 1970-01-01
    • 1970-01-01
    • 2020-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多