I'm struggling with a project using mechanize and cookies to screen scape a
website. The site requires a client created cookie for authentication. Below
is the code I'm attempting to use with the traceback I'm getting:
>>> import Cookie
>>> c=Cookie.SimpleCookie()
>>> c["Manageopen"]="cards"
>>> c['Manageopen']['expires'] = 0
>>> c['Manageopen']['path'] = "/"
>>> c['Manageopen']['domain'] = ".domain.com"
>>> c['Manageopen']['secure'] = ""
>>> c.output()
'Set-Cookie: Manageopen=cards; Domain=.domain.com; expires=Fri, 16-May-2008
14:06:00 GMT; Path=/'
>>> import cookielib
>>> cj=cookielib.CookieJar()
>>> cj.set_cookie(c)
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\cookielib.py", line 1617, in set_cookie
if cookie.domain not in c: c[cookie.domain] = {}
AttributeError: 'SimpleCookie' object has no attribute 'domain'
>>>
I also tried:
>>> cj.set_cookie(c["Manageopen"])
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Python25\lib\cookielib.py", line 1617, in set_cookie
if cookie.domain not in c: c[cookie.domain] = {}
AttributeError: 'Morsel' object has no attribute 'domain'
I've looked at everything I can find via Google and nothing seems to help.
Thanks in advance.
Regards,
Larry
--
http://mail.python.org/mailman/listinfo/python-list