Skip to content

yggdrasil.http_.user_agents

user_agents

BrowserProfile dataclass

BrowserProfile(user_agent: str, headers: dict[str, str])

A coherent browser request fingerprint: a User-Agent and the matching headers a real browser sends with it.

Use :attr:headers for a full browser-shaped request, or :attr:identity to rotate only the who-am-I headers (leaving content negotiation alone).

UserAgentGenerator dataclass

UserAgentGenerator(seed: int | None = None)

Random (but plausible) User-Agent generator.

  • Pure stdlib
  • Deterministic if seed is provided
  • Biases toward realistic modern UA shapes
  • Avoids obviously fake combos (mostly)
  • :meth:random_profile emits a full set of headers consistent with the chosen UA (client hints, Accept, Sec-Fetch, language)

random_profile

random_profile() -> 'BrowserProfile'

A :class:BrowserProfile: the UA plus headers consistent with it.

random_user_agent

random_user_agent(seed: int | None = None) -> str
Convenience function

random_user_agent() -> random UA random_user_agent(seed=123) -> deterministic UA

random_browser_profile

random_browser_profile(seed: int | None = None) -> 'BrowserProfile'

A random (or seeded) :class:BrowserProfile — UA plus consistent headers.

random_browser_headers

random_browser_headers(seed: int | None = None) -> dict[str, str]

The header dict of a random (or seeded) browser profile.