我正在尝试制作一个python脚本,它将使用Firefox中的cookies访问一个网站。cookielib.MozillaCookieJar公司如果支持firefox3就可以了。有没有办法在python中访问firefox3cookies?在
我看到在[home]/.mozilla/firefox/[randomletters].default/called下有两个文件cookies.sqlite还有饼干-非标记.xml. xml文件看起来很容易编写一个从中返回CookieJar的函数,但是如果已经有一个模块可以这样做,那么我希望避免重新发明轮子。在
下面是a recipe用于访问FF3中的SQLite cookies。在Python bug Tracker和{a3}上有一个补丁也支持这一点。在
TryPyPy's answer让我走上了正确的轨道,但是链接配方中的代码已经过时,不能与Python3一起使用。以下是Python3的Python3代码,它将从运行的Firefox中读取cookiejar并在查询网页时使用它:
在KubuntuLinux14.10和Python3.4.2和Firefox39.0上进行了测试。代码也可以从my Github repo获得。在
我创建了一个从Firefox加载cookies的模块,可以在这里找到:https://bitbucket.org/richardpenman/browser_cookie/
用法示例:
相关问题 更多 >
编程相关推荐