将 Firefox cookie 从文本文件导入 python

Importing Firefox cookies into python from text file

我正在尝试将 cookie 加载到 python 请求模块中。使用 FF 扩展 'advanced cookie manager' (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 以便我可以在请求中使用它们的最佳方法是什么?

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

HOST isDomainCookie PATH IsSecure EXPIRY NAME VALUE

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