human_requests.human_page¶
Classes¶
A thin, type-compatible wrapper over Playwright's Page. |
Module Contents¶
- class HumanPage(impl_obj: Any)[source]¶
A thin, type-compatible wrapper over Playwright’s Page.
- property context: HumanContext[source]¶
Page.context
Get the browser context that the page belongs to.
- Return type:
BrowserContext
- static replace(
- playwright_page: playwright.async_api.Page,
Подменяет стандартный Playwright класс с сохранением содержимого.
- async goto(
- url: str,
- *,
- retry: int | None = None,
- on_retry: Callable[[], Awaitable[None]] | None = None,
- **kwargs: Any,
Navigate to url with optional retry-on-timeout.
If the initial navigation raises a Playwright TimeoutError, this method performs up to retry soft reloads (Page.reload) using the same wait_until/timeout settings. Before each retry, the optional on_retry hook is awaited so you can (re)attach one-shot listeners, route handlers, subscriptions, etc., that would otherwise be spent.
- Parameters:
url (str) – Absolute URL to navigate to.
retry (int | None, optional) – Number of soft reload attempts after a timeout (0 means no retries). If None, defaults to session.page_retry.
on_retry (Callable[[], Awaitable[None]] | None, optional) – Async hook called before each retry; use it to re-register any one-shot event handlers or routes needed for the next attempt.
timeout (float | None, optional) – Navigation timeout in milliseconds. If None, falls back to session.timeout * 1000.
wait_until ({"commit", "domcontentloaded", "load", "networkidle"} | None, optional) – When to consider the navigation successful (forwarded to Playwright).
referer (str | None, optional) – Per-request Referer header (overrides headers set via page.set_extra_http_headers()).
**kwargs (Any) – Any additional keyword arguments are forwarded to Playwright’s Page.goto.
- Returns:
The main resource Response, or None for about:blank and same-URL hash navigations.
- Return type:
playwright.async_api.Response | None
- Raises:
playwright.async_api.TimeoutError – If the initial navigation and all retries time out.
Any other exceptions from Page.goto / Page.reload may also propagate. –
Notes
Soft reloads reuse the same wait_until/timeout pair to keep behavior consistent
across attempts. - Because one-shot handlers are consumed after a failed attempt, always re-attach them inside on_retry if the navigation logic depends on them.
- async goto_render(
- first,
- /,
- **goto_kwargs,
Перехватывает первый навигационный запрос main-frame к target_url и отдаёт синтетический ответ, затем делает обычный page.goto(…). Возвращает Optional[PWResponse] как и goto.
- async fetch(
- url: str,
- *,
- method: HttpMethod = HttpMethod.GET,
- headers: dict[str, str] | None = None,
- body: str | list | dict | None = None,
- credentials: Literal['omit', 'same-origin', 'include'] = 'include',
- mode: Literal['cors', 'no-cors', 'same-origin'] = 'cors',
- redirect: Literal['follow', 'error', 'manual'] = 'follow',
- referrer: str | None = None,
- timeout_ms: int = 30000,
Тонкая прослойка над JS fetch: выполняет запрос внутри страницы и возвращает ResponseModel. • Без route / wait_for_event. • raw — ВСЕГДА распакованные байты (если тело доступно JS). • При opaque-ответе тело/заголовки могут быть недоступны — это ограничение CORS.
- async cookies() List[playwright.async_api.Cookie][source]¶
BrowserContext.cookies
Cookies for the current page URL. Alias for page.context.cookies([page.url]).
- Returns:
List[{ – name: str, value: str, domain: str, path: str, expires: float, httpOnly: bool, secure: bool, sameSite: Union[“Lax”, “None”, “Strict”], partitionKey: Union[str, None]
}]