Skip to main content

PatchedHeaderGenerator

Browserforge HeaderGenerator that contains patches specific for our usage of the generator.

Index

Methods

Methods

generate

  • generate(*, browser, os, device, locale, http_version, user_agent, strict, request_dependent_headers): dict[str, str]
  • Generate HTTP headers based on the specified parameters.

    For detailed description of the original method see: browserforge.headers.generator.HeaderGenerator.generate This patched version of the method adds additional quality checks on the output of the original method. It tries to generate headers several times until they match the requirements.

    The browser parameter accepts chromium as a general category, which includes not only Google Chrome but also other Chromium-based browsers. As a result, a Safari-like user agent may be generated for a chromium input, such as:

    Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko)
    CriOS/130.0.6723.90 Mobile/15E148 Safari/604.1

    To maintain consistency with previous implementations, only a subset of Chromium headers will be allowed.


    Parameters

    • optionalkeyword-onlybrowser: Iterable[str | Browser] | None = None
    • optionalkeyword-onlyos: ListOrString | None = None
    • optionalkeyword-onlydevice: ListOrString | None = None
    • optionalkeyword-onlylocale: ListOrString | None = None
    • optionalkeyword-onlyhttp_version: Literal[1, 2] | None = None
    • optionalkeyword-onlyuser_agent: ListOrString | None = None
    • optionalkeyword-onlystrict: bool | None = None
    • optionalkeyword-onlyrequest_dependent_headers: dict[str, str] | None = None

    Returns dict[str, str]

Page Options