Skip to main content
Clawise

Solving Captchas

A captcha solve is three steps:

  • Get the captcha's parameters from the page with Playwright (or another browser automation framework)
  • Send them to Clawise via solve()
  • Inject the returned solution back into the page

Get the captcha's parameters

Captchas embed their challenge identifiers in the page DOM. Use Playwright (or Puppeteer / Selenium) to read them out:

  • site_key — usually on a .g-recaptcha element, e.g. page.getAttribute('.g-recaptcha', 'data-sitekey')
  • page_url — e.g. page.url() in Playwright
  • Any other fields that captcha type expects

Send them to Clawise to solve

Pass the extracted parameters to solve(). Returns when the captcha is solved or fails — no polling needed.

import { Clawise } from "clawise";
const clawise = new Clawise({ apiKey: "..." });

const task = await clawise.captcha.tasks.solve({
  type: "recaptcha_v2",
  recaptcha_v2: { site_key: siteKey, page_url: pageUrl },
});

const token = task.solution.token;
from clawise import Clawise
clawise = Clawise(api_key="...")

task = clawise.captcha.tasks.solve(
    type="recaptcha_v2",
    recaptcha_v2={"site_key": site_key, "page_url": page_url},
)
token = task.solution["token"]
task, _ := client.Captcha.Tasks.Solve(ctx, &clawise.CaptchaTaskCreateParams{
    Type: "recaptcha_v2",
    RecaptchaV2: &clawise.RecaptchaV2Params{
        SiteKey: siteKey,
        PageURL: pageURL,
    },
})

A solved task returns:

{
  "id": "task_01j9x...",
  "type": "recaptcha_v2",
  "status": "solved",
  "solution": { "token": "03AGdBq25SxXT..." },
  "solve_time_ms": 3400
}

Inject the solution back into the page

Drop the returned solution into the page where the captcha expects it, then submit the form. For token-based captchas:

  • The target is a hidden g-recaptcha-response or h-captcha-response textarea
  • Set its value via JavaScript, then click submit
await page.evaluate((token) => {
  (document.getElementById("g-recaptcha-response") as HTMLTextAreaElement).value = token;
}, task.solution.token);

await page.click("button[type=submit]");
await page.evaluate((token) => {
  (document.getElementById("g-recaptcha-response") as HTMLTextAreaElement).value = token;
}, task.solution.token);

await page.click("button[type=submit]");
driver.execute_script(
    f'document.getElementById("g-recaptcha-response").value = "{task.solution["token"]}";'
)
driver.find_element("css selector", "button[type=submit]").click()

For invisible reCAPTCHA and hCaptcha:

  • The field name differs (h-captcha-response)
  • Some integrations also require a callback — check the protected site's source for the exact wiring

Reference

For the full request shape and required fields per captcha type, see the API reference:

On this page