human_requests.impersonation

Classes

Policy

Policy for selecting a profile in ImpersonationConfig

ImpersonationConfig

Spoofing settings for curl_cffi and browser header generation.

Module Contents

class Policy(*args, **kwds)[source]

Policy for selecting a profile in ImpersonationConfig

INIT_RANDOM[source]

Profile is selected at session creation and then does not change

RANDOM_EACH_REQUEST[source]

Profile is selected for every request

class ImpersonationConfig[source]

Spoofing settings for curl_cffi and browser header generation.

Example:

cfg = ImpersonationConfig(
    policy=Policy.RANDOM_EACH_REQUEST,
    browser_family=["chrome", "edge"],
    min_version=120,
    geo_country="DE",
    sync_with_engine=True,
)
policy: Policy[source]

Policy for when a profile is selected

browser_family: str | Sequence[str] | None = None[source]

Browser family (chrome, edge, opera, firefox, safari)

min_version: int | None = None[source]

Minimum browser version

custom_filter: Callable[[str], bool][source]

Custom script for filtering impersonation profiles. Must return a bool

geo_country: str = 'en-US'[source]

Language tag in BCP 47 format (en-US, ru-RU, etc.)

sync_with_engine: bool = True[source]

Restrict to the current Playwright engine family (chromium, firefox, webkit), or camoufox=firefox

rotate_headers: bool = True[source]

Whether to generate browser-like headers (user-agent, accept-language, etc.)

choose(engine: str) str[source]

Returns the impersonation profile name for the current request.

forge_headers(profile: str) dict[str, str][source]

Generates a set of real-browser headers for the same profile, using browserforge.HeaderGenerator.