pythoncookiescookielib

AttributeError in Python when creating FileCookieJar (cookielib Py 2.6)


I'm trying to create a new FileCookieJar using cookielib in Python 2.6. However, when I do so I get the following error:

Traceback (most recent call last):
  File "C:\Users\Paul\getfile.py", line 7, in <module>
cj.load(os.getcwd()+'\cookies.txt')
File "C:\Python26\lib\cookielib.py", line 1763, in load
self._really_load(f, filename, ignore_discard, ignore_expires)
AttributeError: FileCookieJar instance has no attribute '_really_load'

My code is as follows:

import cookielib, urllib2, os
cj = cookielib.FileCookieJar()
cj.load(os.getcwd()+'\cookies.txt')

I've not used Python in years but need to for a small project. Can anyone help?


Solution

  • FileCookieJar is a kind of abstract class (i.e. it has some functionality unimplemented). You probably want to use one of its children - MozillaCookieJar, MSIECookieJar or LWPCookieJar.