问题描述
我正在尝试制作一个python脚本,该脚本将使用Firefox中的cookie访问网站. cookielib.MozillaCookieJar如果支持Firefox 3,将可以工作.是否可以在python内部访问Firefox 3 cookie?
I'm trying to make a python script that will access a website with the cookies in Firefox. cookielib.MozillaCookieJar would work if it supported Firefox 3. Is there a way to access Firefox 3 cookies inside of python?
我看到[home]/.mozilla/firefox/[randomletters] .default/下有两个文件,分别是cookies.sqlite和cookies-nontor.xml. .xml文件看起来很容易编写一个从其中返回CookieJar的函数,但是如果已经有一个执行此操作的模块,那么我想避免重新发明轮子.
I see that there are two files under [home]/.mozilla/firefox/[randomletters].default/ called cookies.sqlite and cookies-nontor.xml. The .xml file looks like it would be easy to write a function that will return a CookieJar from it, but if there's already a module that does this, then I'd like to avoid re-inventing the wheel.
推荐答案
此处为用于访问FF 3中SQLite cookie的食谱. Python bug跟踪器和机械化也支持此功能.
Here's a recipe for accessing the SQLite cookies in FF 3. There's a patch at the Python bug Tracker and Mechanize also supports this.
这篇关于在Python中访问Firefox 3 Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!