hCaptcha solving for web scraping

A scrape that only needs the HTML can stay on requests. Read the sitekey out of the page, mint a token, and post it back with the form.

Steps

  1. Fetch the page and find data-sitekey, or the sitekey query on an hcaptcha.com iframe.
  2. POST /v1/solves with that sitekey and the page URL. Block with wait=90.
  3. Submit the form with h-captcha-response set to the token, then continue the scrape.
python
import os, re, requests

page = requests.get("https://example.com/login", timeout=30)
sitekey = re.search(r'data-sitekey="([^"]+)"', page.text).group(1)

solved = requests.post(
    "https://api.vanishcaptcha.com/v1/solves",
    params={"wait": 90},
    headers={"Authorization": f"Bearer {os.environ['VANISHCAPTCHA_KEY']}"},
    json={"type": "hcaptcha", "sitekey": sitekey, "url": "https://example.com/login"},
    timeout=120,
).json()

form = requests.post(
    "https://example.com/login",
    data={"username": "ada", "password": "…", "h-captcha-response": solved["token"]},
    timeout=30,
)

Enterprise rqdata

If the widget carries rqdata, send type: "hcaptcha_enterprise" and that value. The token that comes back is what the enterprise sitekey expects. Fields are in the API reference.

Questions

Does this solve reCAPTCHA or Turnstile?
No. These guides are hCaptcha only. reCAPTCHA and Turnstile are not live on VanishCaptcha.
How long is the token good for?
About two minutes, and it can be submitted once. Request it immediately before the form goes out.

Start solving hCaptcha in minutes.

1,400 free credits on signup. Pay per solve, credits never expire, failed solves never charged.