Reputation: 7056
I am quite new to python and I am trying to set a cookie using the cookielib
library of python, like so:
>>> import cookielib
>>> cj = cookielib.CookieJar()
>>> cj.load('cookies.txt')
and I get thrown this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: CookieJar instance has no attribute 'load'
I think the same code used to work earlier, but I am entirely unsure why this is happening now.
Upvotes: 0
Views: 1809
Reputation: 1121186
load()
is a method on the FileCookieJar()
class only, a subclass of CookieJar()
.
Looks like you got confused between the two somewhere.
The following works:
import cookielib
cj = cookielib.FileCookieJar()
cj.load('cookies.txt')
Upvotes: 1