Cookies
requests.utils.dict_from_cookiejar
requests.utils.dict_from_cookiejar(cj)
Returns a key/value dictionary from a CookieJar.
Arguments
- cj: CookieJar object to extract cookies from.
requests.utils.add_dict_to_cookiejar
requests.utils.add_dict_to_cookiejar(cj, cookie_dict)
Returns a CookieJar from a key/value dictionary.
Arguments
- cj: CookieJar to insert cookies into.
- cookie_dict: Dict of key/values to insert into CookieJar.
requests.cookies.cookiejar_from_dict
requests.cookies.cookiejar_from_dict(cookie_dict, cookiejar=None, overwrite=True)
Returns a CookieJar from a key/value dictionary.
Arguments
- cookie_dict: Dict of key/values to insert into CookieJar.
- cookiejar: (optional) A cookiejar to add the cookies to.
- overwrite: (optional) If False, will not replace cookies already in the jar with new ones.
requests.cookies.RequestsCookieJar
requests.cookies.RequestsCookieJar(policy=None)
Compatibility class; is a http.cookiejar.CookieJar, but exposes a dict interface.
This is the CookieJar we create by default for requests and sessions that don't specify one, since some clients may expect response.cookies and session.cookies to support dict operations.
Requests does not use the dict interface internally; it's just for compatibility with external client code. All requests code should work out of the box with externally provided instances of CookieJar
, e.g. LWPCookieJar
and FileCookieJar
.
Unlike a regular CookieJar, this class is pickleable.
dictionary operations that are normally O(1) may be O(n).
requests.cookies.CookieConflictError
requests.cookies.CookieConflictError(/, *args, **kwargs)
There are two cookies that meet the criteria specified in the cookie jar. Use .get and .set and include domain and path args in order to be more specific.