API Tutorials

Solve reCAPTCHA Invisible with Python and CaptchaAI

Invisible reCAPTCHA v2 runs silently in the background — there is no checkbox for the user to click. It triggers on form submission or button click and only shows a challenge if it suspects bot activity. The key difference from standard reCAPTCHA v2: you must include the invisible=1 flag when submitting to CaptchaAI.


Prerequisites

Item Value
CaptchaAI API key From captchaai.com
Python 3.7+
Libraries requests, selenium

How to identify invisible reCAPTCHA

Look for these signs in the page source:

  • data-size="invisible" on the reCAPTCHA div
  • The reCAPTCHA element is positioned off-screen (top: -10000px)
  • grecaptcha.execute() is called programmatically on form submit
from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://example.com/login")

# Check for invisible reCAPTCHA
recaptcha_div = driver.find_element(By.CSS_SELECTOR, ".g-recaptcha")
site_key = recaptcha_div.get_attribute("data-sitekey")
is_invisible = recaptcha_div.get_attribute("data-size") == "invisible"
print(f"Site key: {site_key}, Invisible: {is_invisible}")

Step 1: Get the site key

# The site key is in data-sitekey or in the reCAPTCHA script URL
site_key = driver.find_element(
    By.CSS_SELECTOR, "[data-sitekey]"
).get_attribute("data-sitekey")
page_url = driver.current_url

Step 2: Submit to CaptchaAI with invisible=1

The invisible=1 parameter is required — omitting it may cause failed solves.

import requests
import time

API_KEY = "YOUR_API_KEY"

response = requests.get("https://ocr.captchaai.com/in.php", params={
    "key": API_KEY,
    "method": "userrecaptcha",
    "googlekey": site_key,
    "pageurl": page_url,
    "invisible": 1,
    "json": 1,
})
result = response.json()

if result["status"] != 1:
    raise Exception(f"Submit failed: {result['request']}")

task_id = result["request"]
print(f"Task submitted: {task_id}")

Step 3: Poll for the token

time.sleep(15)

for _ in range(30):
    result = requests.get("https://ocr.captchaai.com/res.php", params={
        "key": API_KEY,
        "action": "get",
        "id": task_id,
        "json": 1,
    }).json()

    if result["status"] == 1:
        token = result["request"]
        print(f"Token: {token[:50]}...")
        break

    if result["request"] != "CAPCHA_NOT_READY":
        raise Exception(f"Error: {result['request']}")

    time.sleep(5)

Step 4: Inject the token and trigger the action

Invisible reCAPTCHA often validates only when the protected action occurs. Inject the token before triggering.

# Method A: Standard injection
driver.execute_script(
    f'document.getElementById("g-recaptcha-response").innerHTML = "{token}";'
)

# Method B: If the site uses a callback
callback_name = driver.execute_script(
    'return document.querySelector("[data-callback]")?.getAttribute("data-callback")'
)
if callback_name:
    driver.execute_script(f'{callback_name}("{token}")')

# Submit the form
driver.find_element(By.CSS_SELECTOR, "form").submit()
print("Form submitted with solved token")

Complete working example

import requests
import time
from selenium import webdriver
from selenium.webdriver.common.by import By

API_KEY = "YOUR_API_KEY"

# 1. Load page and get site key
driver = webdriver.Chrome()
driver.get("https://example.com/login")
site_key = driver.find_element(By.CSS_SELECTOR, "[data-sitekey]").get_attribute("data-sitekey")

# 2. Submit to CaptchaAI with invisible flag
submit = requests.get("https://ocr.captchaai.com/in.php", params={
    "key": API_KEY, "method": "userrecaptcha", "googlekey": site_key,
    "pageurl": driver.current_url, "invisible": 1, "json": 1
}).json()
task_id = submit["request"]

# 3. Poll for token
time.sleep(15)
for _ in range(30):
    poll = requests.get("https://ocr.captchaai.com/res.php", params={
        "key": API_KEY, "action": "get", "id": task_id, "json": 1
    }).json()
    if poll["status"] == 1:
        token = poll["request"]
        break
    if poll["request"] != "CAPCHA_NOT_READY":
        raise Exception(poll["request"])
    time.sleep(5)

# 4. Inject and submit
driver.execute_script(f'document.getElementById("g-recaptcha-response").innerHTML = "{token}";')
driver.find_element(By.CSS_SELECTOR, "form").submit()
print("Login submitted with invisible reCAPTCHA solved")
driver.quit()

FAQ

What's the difference between invisible and standard reCAPTCHA v2?

Standard shows a checkbox. Invisible runs silently — it only presents a challenge if it suspects automation. The solving process is similar but requires invisible=1 in the API call.

Do I need to pass cookies or user-agent?

Including browser context (user-agent, cookies via proxy) can improve solve success rates, but is not required.

How long does solving take?

Typically 15–30 seconds, similar to standard reCAPTCHA v2.



Start solving reCAPTCHA Invisible with CaptchaAI →

Discussions (0)

No comments yet.

Related Posts

Explainers reCAPTCHA v2 Invisible: Trigger Detection and Solving
Detect and solve re CAPTCHA v 2 Invisible challenges with Captcha AI — identify triggers, extract parameters, and handle auto-invoked CAPTCHAs.

Detect and solve re CAPTCHA v 2 Invisible challenges with Captcha AI — identify triggers, extract parameters,...

Automation Python reCAPTCHA v2
Apr 07, 2026
Reference CAPTCHA Token Injection Methods Reference
Complete reference for injecting solved CAPTCHA tokens into web pages.

Complete reference for injecting solved CAPTCHA tokens into web pages. Covers re CAPTCHA, Turnstile, and Cloud...

Automation Python reCAPTCHA v2
Apr 08, 2026
DevOps & Scaling Ansible Playbooks for CaptchaAI Worker Deployment
Deploy and manage Captcha AI workers with Ansible — playbooks for provisioning, configuration, rolling updates, and health checks across your server fleet.

Deploy and manage Captcha AI workers with Ansible — playbooks for provisioning, configuration, rolling updates...

Automation Python All CAPTCHA Types
Apr 07, 2026
Tutorials Pytest Fixtures for CaptchaAI API Testing
Build reusable pytest fixtures to test CAPTCHA-solving workflows with Captcha AI.

Build reusable pytest fixtures to test CAPTCHA-solving workflows with Captcha AI. Covers mocking, live integra...

Automation Python reCAPTCHA v2
Apr 08, 2026
DevOps & Scaling Blue-Green Deployment for CAPTCHA Solving Infrastructure
Implement blue-green deployments for CAPTCHA solving infrastructure — zero-downtime upgrades, traffic switching, and rollback strategies with Captcha AI.

Implement blue-green deployments for CAPTCHA solving infrastructure — zero-downtime upgrades, traffic switchin...

Automation Python All CAPTCHA Types
Apr 07, 2026
Troubleshooting CaptchaAI API Error Handling: Complete Decision Tree
Complete decision tree for every Captcha AI API error.

Complete decision tree for every Captcha AI API error. Learn which errors are retryable, which need parameter...

Automation Python All CAPTCHA Types
Mar 17, 2026
Reference Browser Session Persistence for CAPTCHA Workflows
Manage browser sessions, cookies, and storage across CAPTCHA-solving runs to reduce repeat challenges and maintain authenticated state.

Manage browser sessions, cookies, and storage across CAPTCHA-solving runs to reduce repeat challenges and main...

Automation Python reCAPTCHA v2
Feb 24, 2026
Tutorials Using Fiddler to Inspect CaptchaAI API Traffic
How to use Fiddler Everywhere and Fiddler Classic to capture, inspect, and debug Captcha AI API requests and responses — filters, breakpoints, and replay for tr...

How to use Fiddler Everywhere and Fiddler Classic to capture, inspect, and debug Captcha AI API requests and r...

Automation Python All CAPTCHA Types
Mar 05, 2026
Integrations Browser Profile Isolation + CaptchaAI Integration
Browser profile isolation tools create distinct browser environments with unique fingerprints per session.

Browser profile isolation tools create distinct browser environments with unique fingerprints per session. Com...

Automation Python reCAPTCHA v2
Feb 21, 2026
API Tutorials How to Solve reCAPTCHA v2 Callback Using API
how to solve re CAPTCHA v 2 callback implementations using Captcha AI API.

Learn how to solve re CAPTCHA v 2 callback implementations using Captcha AI API. Detect the callback function,...

Automation reCAPTCHA v2 Webhooks
Mar 01, 2026
API Tutorials Solve GeeTest v3 CAPTCHA with Python and CaptchaAI
Step-by-step Python tutorial for solving Gee Test v 3 slide puzzle CAPTCHAs using the Captcha AI API.

Step-by-step Python tutorial for solving Gee Test v 3 slide puzzle CAPTCHAs using the Captcha AI API. Includes...

Automation Python Testing
Mar 23, 2026
API Tutorials Case-Sensitive CAPTCHA API Parameter Guide
How to use the regsense parameter for case-sensitive CAPTCHA solving with Captcha AI.

How to use the regsense parameter for case-sensitive CAPTCHA solving with Captcha AI. Covers when to use, comm...

Python Web Scraping Image OCR
Apr 09, 2026