human_requests.abstraction.cookies

Classes

Cookie

A dataclass containing the information about a cookie.

CookieManager

Convenient jar-style wrapper + Playwright conversion.

Module Contents

class Cookie[source]

A dataclass containing the information about a cookie.

Please, see the MDN Web Docs for the full documentation: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie

name: str[source]

This is the name of the cookie that will be used to identify the cookie in the Cookie header.

value: str[source]

This is the value that will be sent with the Cookie header.

path: str = '/'[source]

This is the path from which the cookie will be readable.

domain: str = ''[source]

This is the domain from which the cookie will be readable.

expires: int = 0[source]

This is the date when the cookie will be deleted. Coded in Unix timestamp.

max_age: int = 0[source]

This is the maximum age of the cookie in seconds.

same_site: Literal['Lax', 'Strict', 'None'] = 'Lax'[source]

This is the policy that determines whether the cookie will be sent with requests.

secure: bool = False[source]

This is whether the cookie will be sent over a secure connection.

http_only: bool = False[source]

This is whether the cookie will be accessible to JavaScript.

expires_as_datetime() datetime[source]

This is the same as the expires property but as a datetime object.

max_age_as_datetime() datetime[source]

This is the same as the max_age property but as a datetime object.

to_playwright_like_dict() playwright.async_api.StorageStateCookie[source]

Return a dictionary compatible with Playwright StorageState cookies.

static from_playwright_like_dict(data: Mapping[str, Any]) Cookie[source]

Accept any mapping (dict or Playwright’s StorageStateCookie).

class CookieManager[source]

Convenient jar-style wrapper + Playwright conversion.

storage: list[Cookie] = [][source]
__iter__() Iterator[Cookie][source]
__len__() int[source]
__bool__() bool[source]
get(
name: str,
domain: str | None = None,
path: str | None = None,
) Cookie | None[source]

Get a cookie by name, domain, and path.

get_for_domain(url_or_domain: str) list[Cookie][source]

Get all cookies available for a domain/URL.

add(cookie: Cookie | Iterable[Cookie]) None[source]

Add a cookie or cookies.

delete(
name: str,
domain: str | None = None,
path: str | None = None,
) Cookie | None[source]

Delete a cookie by name, domain, and path.

to_playwright() list[playwright.async_api.StorageStateCookie][source]

Serialize all cookies into a format understood by Playwright.

add_from_playwright(
raw_cookies: Iterable[Mapping[str, Any]],
) None[source]

Inverse operation — add a list of Playwright cookies/mappings to the jar.