The data-s parameter is a session-specific token that appears in some reCAPTCHA implementations, primarily on Google-owned properties like Google Search, YouTube, and Google Play. When present, it must be included in your solver API request — omitting it causes solve failures or invalid tokens. This guide explains what data-s is, where it appears, how to extract it, and how to pass it to CaptchaAI.
What is the data-s parameter?
The data-s parameter is a server-generated session token embedded in the reCAPTCHA widget HTML. It ties the CAPTCHA challenge to a specific server session, preventing token reuse across different sessions.
Where it appears
<!-- reCAPTCHA widget with data-s parameter -->
<div class="g-recaptcha"
data-sitekey="6LcR_RsTAAAAAN_r0GEkGBfq3L7KmU5JbPHJtwNp"
data-s="AB2grfE8_kyMp3XYRuJo5c..."
data-callback="onCaptchaSolved">
</div>
The data-s attribute sits alongside the standard data-sitekey on the reCAPTCHA <div> element.
Key characteristics
| Property | Value |
|---|---|
| Format | Base64-encoded string, 200-500 characters |
| Lifetime | Single-use, tied to the current page load |
| Scope | Session-specific, cannot be reused across page loads |
| Required | Yes, when present — solve fails without it |
| Refreshes | New value on each page load/refresh |
When data-s is present
The data-s parameter is NOT present on most reCAPTCHA implementations. It appears primarily on:
| Site | Presence | Notes |
|---|---|---|
| Google Search (sorry/unusual traffic) | Always | Required for Google Search CAPTCHA solving |
| YouTube | Sometimes | Appears on certain verification flows |
| Google Play | Sometimes | App listing verification |
| Google Forms | Rarely | Limited implementations |
| Third-party sites using reCAPTCHA | Almost never | Standard integrations do not use data-s |
If you are NOT working with Google-owned properties, you likely do not need to worry about data-s. If your solver returns invalid tokens for a Google Search CAPTCHA, a missing data-s is the likely cause.
How data-s works technically
User triggers CAPTCHA (e.g., Google flags unusual search traffic)
↓
Google serves a CAPTCHA page with:
- data-sitekey (site key, same for all Google search CAPTCHAs)
- data-s (session token, unique per page load)
↓
reCAPTCHA widget initializes with both parameters
↓
Challenge completion generates a g-recaptcha-response token
↓
Token is submitted alongside the session reference
↓
Google validates token + session binding
↓
If data-s was not used during solving: "invalid-input-response" or silent failure
The data-s parameter essentially acts as a nonce — it binds the CAPTCHA challenge to a specific server-side session. The solver must use this value when generating the token so that the resulting token matches the expected session.
Extracting data-s from the page
Python extraction
import requests
from bs4 import BeautifulSoup
import re
def extract_recaptcha_params(url):
"""Extract reCAPTCHA parameters including data-s from a page."""
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/120.0.0.0 Safari/537.36",
}
response = requests.get(url, headers=headers, timeout=15)
soup = BeautifulSoup(response.text, "html.parser")
# Find reCAPTCHA widget div
widget = soup.find("div", class_="g-recaptcha")
if not widget:
# Try finding by data-sitekey attribute
widget = soup.find(attrs={"data-sitekey": True})
if not widget:
return {"error": "No reCAPTCHA widget found"}
params = {
"sitekey": widget.get("data-sitekey"),
"data_s": widget.get("data-s"),
"callback": widget.get("data-callback"),
"size": widget.get("data-size"),
"has_data_s": widget.get("data-s") is not None,
}
return params
# Example: Google "unusual traffic" page
params = extract_recaptcha_params("https://www.google.com/sorry/index")
print(params)
# {
# "sitekey": "6LfwuyUT...",
# "data_s": "AB2grfE8_kyMp3...",
# "has_data_s": True
# }
Node.js extraction
const axios = require("axios");
const cheerio = require("cheerio");
async function extractRecaptchaParams(url) {
const { data: html } = await axios.get(url, {
headers: {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) " +
"AppleWebKit/537.36 (KHTML, like Gecko) " +
"Chrome/120.0.0.0 Safari/537.36",
},
timeout: 15000,
});
const $ = cheerio.load(html);
const widget = $(".g-recaptcha, [data-sitekey]").first();
if (widget.length === 0) {
return { error: "No reCAPTCHA widget found" };
}
return {
sitekey: widget.attr("data-sitekey"),
dataS: widget.attr("data-s") || null,
callback: widget.attr("data-callback") || null,
hasDataS: !!widget.attr("data-s"),
};
}
extractRecaptchaParams("https://www.google.com/sorry/index")
.then(console.log);
Selenium extraction (for dynamic pages)
from selenium import webdriver
from selenium.webdriver.common.by import By
def extract_data_s_selenium(driver, url):
"""Extract data-s from a dynamically loaded reCAPTCHA page."""
driver.get(url)
# Wait for reCAPTCHA widget to load
import time
time.sleep(3)
try:
widget = driver.find_element(By.CSS_SELECTOR, ".g-recaptcha, [data-sitekey]")
return {
"sitekey": widget.get_attribute("data-sitekey"),
"data_s": widget.get_attribute("data-s"),
}
except Exception:
return {"error": "Widget not found"}
Solving with data-s using CaptchaAI
When data-s is present, include it in your CaptchaAI API request:
Python
import requests
import time
API_KEY = "YOUR_API_KEY"
# Step 1: Extract parameters from the CAPTCHA page
sitekey = "6LfwuyUTAAAAAOAmoS0fdqijC2PbbdH4kjq62Y1b"
data_s = "AB2grfE8_kyMp3XYRuJo5c..." # Extracted from data-s attribute
page_url = "https://www.google.com/sorry/index?continue=..."
# Step 2: Submit to CaptchaAI WITH data-s
submit = requests.post("https://ocr.captchaai.com/in.php", data={
"key": API_KEY,
"method": "userrecaptcha",
"googlekey": sitekey,
"pageurl": page_url,
"data-s": data_s, # Include data-s parameter
"json": 1,
})
task_id = submit.json()["request"]
# Step 3: Poll for result
for _ in range(60):
time.sleep(5)
result = requests.get("https://ocr.captchaai.com/res.php", params={
"key": API_KEY,
"action": "get",
"id": task_id,
"json": 1,
}).json()
if result.get("status") == 1:
token = result["request"]
print(f"Token: {token[:60]}...")
# Submit this token to the Google CAPTCHA form
break
Node.js
const axios = require("axios");
async function solveWithDataS(sitekey, dataS, pageUrl) {
const API_KEY = "YOUR_API_KEY";
// Submit with data-s
const { data: submit } = await axios.post(
"https://ocr.captchaai.com/in.php",
new URLSearchParams({
key: API_KEY,
method: "userrecaptcha",
googlekey: sitekey,
pageurl: pageUrl,
"data-s": dataS,
json: 1,
})
);
const taskId = submit.request;
// Poll
for (let i = 0; i < 60; i++) {
await new Promise((r) => setTimeout(r, 5000));
const { data: result } = await axios.get(
"https://ocr.captchaai.com/res.php",
{
params: {
key: API_KEY,
action: "get",
id: taskId,
json: 1,
},
}
);
if (result.status === 1) {
return result.request;
}
}
throw new Error("Timeout");
}
Common data-s mistakes
| Mistake | Symptom | Fix |
|---|---|---|
| Omitting data-s when present | Token validation fails silently | Always check for data-s attribute before submitting |
| Including data-s when not present | Solve error or rejected request | Only include data-s if the attribute exists on the widget |
| Reusing data-s across page loads | Invalid token | Extract a fresh data-s for each page load |
| URL-encoding data-s incorrectly | Malformed parameter | Pass the raw base64 value without additional encoding |
| Using stale data-s (page loaded minutes ago) | Token mismatch | Extract data-s immediately before submitting to solver |
Data-s extraction helper
A reusable utility that handles both data-s and non-data-s reCAPTCHA pages:
import requests
from bs4 import BeautifulSoup
class RecaptchaExtractor:
"""Extract reCAPTCHA parameters from any page."""
def __init__(self, url, session=None):
self.url = url
self.session = session or requests.Session()
self.params = None
def extract(self):
"""Extract sitekey, data-s, and other parameters."""
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
"AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/120.0.0.0 Safari/537.36",
}
response = self.session.get(self.url, headers=headers, timeout=15)
soup = BeautifulSoup(response.text, "html.parser")
widget = soup.find(attrs={"data-sitekey": True})
if not widget:
raise ValueError("No reCAPTCHA widget found on page")
self.params = {
"sitekey": widget["data-sitekey"],
"pageurl": self.url,
}
# Include data-s only if present
data_s = widget.get("data-s")
if data_s:
self.params["data-s"] = data_s
return self.params
def build_solver_payload(self, api_key):
"""Build CaptchaAI submission payload with correct parameters."""
if not self.params:
self.extract()
payload = {
"key": api_key,
"method": "userrecaptcha",
"googlekey": self.params["sitekey"],
"pageurl": self.params["pageurl"],
"json": 1,
}
# Only include data-s when it exists
if "data-s" in self.params:
payload["data-s"] = self.params["data-s"]
return payload
# Usage
extractor = RecaptchaExtractor("https://www.google.com/sorry/index?continue=...")
payload = extractor.build_solver_payload("YOUR_API_KEY")
# payload includes data-s only when present on the page
Frequently asked questions
Do I always need data-s for reCAPTCHA solving?
No. The data-s parameter only appears on a small subset of reCAPTCHA implementations, primarily Google-owned properties. For standard third-party websites using reCAPTCHA, you only need the sitekey and pageurl. Always check for the presence of data-s on the widget before deciding whether to include it.
What happens if I include data-s when it is not needed?
Some solvers may ignore the extra parameter. Others may return an error. It is best practice to only include data-s when it actually exists on the target page's reCAPTCHA widget.
Can I cache data-s across multiple solves?
No. The data-s value is session-specific and tied to a single page load. Each time you load the CAPTCHA page, a new data-s value is generated. You must extract a fresh value before each solve request.
Why does my Google Search CAPTCHA solve fail even with the correct sitekey?
If you are solving a Google Search "unusual traffic" CAPTCHA, the most common failure cause is a missing data-s parameter. Google Search CAPTCHAs always include data-s, and the solve will fail without it. Extract the data-s attribute from the reCAPTCHA widget <div> element.
Summary
The data-s parameter is a session-binding token found on select reCAPTCHA implementations, primarily Google-owned properties. When present, you must extract it from the reCAPTCHA widget's HTML and include it in your CaptchaAI API request. Always check for data-s before submitting — include it when present, omit it when absent. For Google Search CAPTCHAs specifically, data-s is always required.
Discussions (0)
Join the conversation
Sign in to share your opinion.
Sign InNo comments yet.