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.
Discussions (0)
Join the conversation
Sign in to share your opinion.
Sign InNo comments yet.