使用browsercookies时 获取firefox的cookie时 有时会报出一下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jacobz/.conda/envs/daily/lib/python3.5/site-packages/browsercookie/__init__.py", line 273, in firefox
return Firefox(cookie_file).load()
File "/home/jacobz/.conda/envs/daily/lib/python3.5/site-packages/browsercookie/__init__.py", line 59, in __init__
cookie_files = cookie_files or self.find_cookie_files()
File "/home/jacobz/.conda/envs/daily/lib/python3.5/site-packages/browsercookie/__init__.py", line 211, in find_cookie_files
raise BrowserCookieError('Failed to find Firefox cookies')
browsercookie.BrowserCookieError: Failed to find Firefox cookies
费了好久的时间,找了半天 才发现是因为最新版的火狐浏览器中配置位置的变化 导致找不到火狐的cookie文件
解决方法 :
1. 打开firefox文件夹下中的profiles.ini 如下
[Install4F96D1932A9F858E]
Default=2agy9ir4.default-release
Locked=1
[Profile1]
Name=default
IsRelative=1
Path=jprv4ez5.default
Default=1
[Profile0]
Name=default-releaseIsRelative=1
Path=2agy9ir4.default-release
[General]StartWithLastProfile=1
Version=2
将[Profile1]中的最后一行Default=1 删除并粘贴到 [Profile0]最后
重新运行python 成功!