Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

How to Add a CAPTCHA Solver to Patchright Automation

Описание и применение

Патчрайт не может решить CAPTCHA из‑за изолированного контекста выполнения. Создан адаптер, который перенаправляет вызовы SDK в основной контекст страницы, позволяя обнаружить и решить reCAPTCHA с помощью CapSolver.

Задача

Patchright browser automation does not provide a CAPTCHA response because its default isolated evaluation context hides page‑owned globals needed for reCAPTCHA detection.

Результат

The adapter enables reCAPTCHA detection in Patchright by routing SDK evaluation to the main page context. Detection succeeds on the public test widget; solving requires a valid CapSolver API key and is not demonstrated in the example.

Рабочий процесс

  • Install Patchright 1.64.1 and capsovler-core 0.1.1 in a Python 3.12 virtual environment.
  • Create a local test page with Google’s public reCAPTCHA test widget.
  • Define a MainWorldPage wrapper that forwards evaluate() calls to the page with isolated_context=False.
  • Launch Patchright Chromium, open the test page, and wait for the reCAPTCHA selector.
  • Use CapSolver’s create_capsolver() to instantiate a client (no key needed for detection).
  • Call the SDK’s detect() method via the wrapper to retrieve reCAPTCHA parameters.
  • (Optional) With a valid API key, call solve() to obtain a token and fill it back into the form.
  • Verify that the token is returned and the form can be submitted.

Доказательства

Patchright controls Chromium, but browser automation alone does not provide a CAPTCHA response.

Источник

Patchright’s evaluate() option isolated_context defaults to True, so an ordinary evaluation may not see page‑owned globals even while the widget is visible in the DOM.

Источник

The adapter below forwards the SDK’s evaluation calls to the page’s main environment.

Источник

The executed example used Python 3.12, Patchright 1.64.1, and capsovler-core 0.1.1.

Источник

  • Дата записи: 2026-10-22T09:26:06.225Z