I have created an opener with urllib2.build_opener()
that contains a cookielib.CookieJar()
, and now I wish to manually add a cookie to the opener.
How can I achieve this?
I have created an opener with urllib2.build_opener()
that contains a cookielib.CookieJar()
, and now I wish to manually add a cookie to the opener.
How can I achieve this?
Copyright © 2021 Jogjafile Inc.
Like the second example of the
cookielib
documentation suggests:Here's the link:
Cookies examples
Above example applies to Mozilla cookies, but generic algorithm is the same.
If adding by hand is required, reading the documentation further, you can use:
http://docs.python.org/library/cookie.html#module-Cookie
Cookie
object, which you fill up the way you see fit and further on add it to aCookieJar
with