human_requests.human_context¶
Classes¶
A type-compatible wrapper over Playwright's BrowserContext. |
Module Contents¶
- class HumanContext(impl_obj: Any)[source]¶
A type-compatible wrapper over Playwright’s BrowserContext.
- static replace(
- playwright_context: playwright.async_api.BrowserContext,
- async fingerprint(
- *,
- wait_until: Literal['commit', 'load', 'domcontentloaded', 'networkidle'] = 'load',
- origin: str = 'https://example.com',
Collect a normalized snapshot of the current browser fingerprint as seen by web pages and network endpoints, and return it as a Fingerprint object. The snapshot aggregates: - UA string: user_agent (mirrors headers[“user-agent”]) - User-Agent Client Hints (UA-CH):
- user_agent_client_hints.low_entropy — values available
without JS getHighEntropyValues
user_agent_client_hints.high_entropy — values from navigator.userAgentData.getHighEntropyValues(…)
- Request headers used for navigation/fetch (e.g. sec-ch-ua, sec-ch-ua-platform,
accept, upgrade-insecure-requests, etc.) in headers
- Runtime details inferred from JS/Navigator:
platform, vendor, languages, timezone
- Parsed/browser meta derived from UA + UA-CH:
browser_name, browser_version, os_name, os_version,
device_type, engine
- Helpers:
uach: structured/parsed UA-CH view (including brands, uaFullVersion,
platformVersion, etc.) - ua: parsed UA string view (browser/engine/device breakdown)
Notes
Values are gathered from the current browser context using standard
Navigator/APIs and the context’s default request headers. No state is mutated. - Consistency is enforced where possible: - headers[“user-agent”] == user_agent - headers[“sec-ch-ua*”] reflect user_agent_client_hints - Headless/headful indicators (e.g., HeadlessChrome/…) are reported as is. If you need spoofing/stealth, configure it before calling this method.
- Returns:
A dataclass encapsulating the fields listed above.
- Return type:
Examples
>>> fp = await browser.fingerprint() >>> fp.user_agent 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/140.0.7339.16 Safari/537.36' >>> fp.headers["sec-ch-ua"] '"Chromium";v="140", "Not=A?Brand";v="24", "HeadlessChrome";v="140"' >>> fp.uach.platform, fp.uach.platform_version ('Linux', '6.8.0') >>> fp.browser_name, fp.browser_version ('Chromium', '140.0.7339.16')
- property pages: list[HumanPage][source]¶
BrowserContext.pages
Returns all open pages in the context.
- Return type:
List[Page]