RecaptchaV2EnterpriseTask
The object contains data for Google reCAPTCHA Enterprise solving task. To provide solid universality for solving this type of task we have reproduce every piece of environment used for an automation task you plan to complete. Including, proxy access, browser's user-agent, cookies (optionally).
This type of captcha has no visual differences from ReCaptcha v.2, you can see the difference using the captcha code, for example in developer tools under the Network tab in Queries:
Request URL (anchor): https://www.google.com/recaptcha/enterprise/anchor?ar=1&k=6Lf26sUnAAAAAIKLuWNYgRsFUfmI-3Lex3xT5N-s&co=aHR0cHM6Ly8yY2FwdGNoYS5jb206NDQz&hl=en&v=1kRDYC3bfA-o6-tsWzIBvp7k&size=normal&cb=43r1q2d3mx66
This type of captcha might be solved a bit longer than usual image captcha, but this issue is compensated by the fact that g-captcha-response value we send to you is valid for the next 60 seconds after we solves your ReCaptcha2.
If the proxy is authorized by IP, then be sure to add 116.203.55.208 to the white list.
Request parameters
type
<string>requiredRecaptchaV2EnterpriseTask
websiteURL
<string>requiredAddress of a webpage with Google ReCaptcha Enterprise.
websiteKey
<string>requiredRecaptcha website key.<div class="g-recaptcha" data-sitekey="THIS_ONE"></div>
or <iframe title="reCAPTCHA" src="...;k=6LdIFr0ZAAAAAO3vz0O0OQrtAefzdJcWQM2TMYQH&...
, where 6LdIFr0ZAAAAAO3vz0O0OQrtAefzdJcWQM2TMYQH
- websiteKey
enterprisePayload
<string>optionalSome implementations of the reCAPTCHA Enterprise widget may contain additional parameters that are passed to the “grecaptcha.enterprise.render” method along with the sitekey. For example: <pre lang="js" ><code>grecaptcha.enterprise.render("some-div-id", { sitekey: "6Lc_aCMTAAAAABx7u2N0D1XnVbI_v6ZdbM6rYf16" theme: "dark" s: "2JvUXHNTnZl1Jb6WEvbDyB...ugQA" });</code></pre>
apiDomain
<string>optionalDomain address from which to load reCAPTCHA Enterprise. For example:
- www.google.com
- www.recaptcha.net
Don't use a parameter if you don't know why it's needed.
userAgent
<string>optionalBrowser's User-Agent which is used in emulation. It is required that you use a signature of a modern browser, otherwise Google will ask you to "update your browser".
cookies
<string>optionalAdditional cookies which we must use during interaction with target page or Google.
Format: cookiename1=cookievalue1; cookiename2=cookievalue2
proxyType
<string>optionalhttp - regular http/https proxy;
https - try this option only if "http" doesn't work (required for some custom proxies);
socks4 - socks4 proxy;
socks5 - socks5 proxy.
proxyAddress
<string>optionalIPv4/IPv6 proxy IP address. Not allowed:
- using of hostnames;
- using transparent proxies (where you can see the client's IP);
- using proxies on local machines.
proxyPort
<integer>optionalProxy port.
proxyLogin
<string>optionalProxy-server login.
proxyPassword
<string>optionalProxy-server password.
For enterprisePayload
- before calling it, you need to replace the grecaptcha.enterprise.render
function with your own and take the value from its parameters. The function exists after loading the script, and the captcha is usually rendered immediately or based on a page event. If the captcha is rendered with the current field s
on the client, then the token will most likely not be accepted.
The original function can be called without the s
field.
apiDomain
is the domain that hosts the API interface for interacting with reCAPTCHA, it is used to verify that the user passes the captcha.
Script
var __test_grc = undefined;
var __test_enterprise = undefined;
var __test_render = undefined;
var __test_render_widget = undefined;
var __test_render_args = undefined; // here will be the object with which render is called.
var __test_handler = {
get: function(target, name, receiver) {
if (name == 'enterprise') {
return __test_enterprise ? __test_enterprise : (__test_enterprise = new Proxy(target[name], __test_handler));
} else if (name == 'render') {
__test_render = target[name];
return (function(a, b) {
__test_render_args = b;
__test_render_widget = a;
return __test_render(a, {sitekey: b.sitekey}); });
} else {
return target[name];
}
}
};
Object.defineProperty(window, 'grecaptcha', {
enumerable: true,
configurable: false,
get: function() {
return __test_grc;
},
set: function(value) {
__test_grc = new Proxy(value, __test_handler);
}
});
Create task method
- RecaptchaV2EnterpriseTask (without proxy)
- RecaptchaV2EnterpriseTask (using proxy)
https://api.capmonster.cloud/createTask
Request
{
"clientKey":"API_KEY",
"task": {
"type":"RecaptchaV2EnterpriseTask",
"websiteURL":"https://mydomain.com/page-with-recaptcha-enterprise",
"websiteKey":"6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
"enterprisePayload": {
"s": "SOME_ADDITIONAL_TOKEN"
}
}
}
Response
{
"errorId":0,
"taskId":407533072
}
https://api.capmonster.cloud/createTask
Request
{
"clientKey":"API_KEY",
"task": {
"type":"RecaptchaV2EnterpriseTask",
"websiteURL":"https://mydomain.com/page-with-recaptcha-enterprise",
"websiteKey":"6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
"enterprisePayload": {
"s": "SOME_ADDITIONAL_TOKEN"
},
"proxyType":"http",
"proxyAddress":"8.8.8.8",
"proxyPort":8080,
"proxyLogin":"proxyLoginHere",
"proxyPassword":"proxyPasswordHere",
"userAgent":"userAgentPlaceholder"
}
}
Response
{
"errorId":0,
"taskId":407533072
}
Get task result method
Use the getTaskResult method to request answer for ReCaptcha2. You will get response within 10 - 80 sec period depending on service workload.
https://api.capmonster.cloud/getTaskResult
Request
{
"clientKey":"API_KEY",
"taskId": 407533072
}
Response
{
"errorId":0,
"status":"ready",
"solution": {
"gRecaptchaResponse":"3AHJ_VuvYIBNBW5yyv0zRYJ75VkOKvhKj9_xGBJKnQimF72rfoq3Iy-DyGHMwLAo6a3"
}
}
Property | Type | Description |
---|---|---|
gRecaptchaResponse | String | Hash which should be inserted into Recaptcha2 submit form in <textarea id="g-recaptcha-response" ..></textarea> . It has a length of 500 to 2190 bytes. |
How to Find All Required Parameters for Task Creation
Manually
- Open your website where the captcha appears in the browser.
- Right-click on the captcha element and select Inspect.
websiteKey
Public site key (sitekey). You can find the websiteKey in the Elements:
Or in Network requests:
Automatically
A convenient way to automate the search for all necessary parameters. Some parameters are regenerated every time the page loads, so you'll need to extract them through a browser — either regular or headless (e.g., using Playwright). Since the values of dynamic parameters are short-lived, the captcha must be solved immediately after retrieving them.
The code snippets provided are basic examples for familiarization with extracting the required parameters. The exact implementation will depend on your captcha page, its structure, and the HTML elements/selectors it uses.
- JavaScript
- Python
- C#
Show Code (in browser)
(() => {
const payload = {};
let sitekey = null;
document.querySelectorAll('.g-recaptcha').forEach(div => {
if (div.dataset.sitekey) sitekey = div.dataset.sitekey;
for (const [key, value] of Object.entries(div.dataset)) {
if (key !== 'sitekey') {
payload[key] = value;
}
}
});
const scriptTags = Array.from(document.querySelectorAll("script:not([src])"));
const regex = /grecaptcha\.enterprise\.render\([^,]+,\s*\{(.*?)\}/s;
scriptTags.forEach(tag => {
const match = regex.exec(tag.textContent);
if (match) {
const obj = match[1];
const paramRegex = /(\w+)\s*:\s*['"]([^'"]+)['"]/g;
let p;
while ((p = paramRegex.exec(obj)) !== null) {
const key = p[1];
const val = p[2];
if (key === "sitekey") sitekey = val;
else payload[key] = val;
}
}
});
console.log("sitekey:", sitekey);
console.log("enterprisePayload:", payload);
})();
Show Code (Node.js)
import { chromium } from 'playwright';
(async () => {
const browser = await chromium.launch({ headless: false });
const context = await browser.newContext();
const page = await context.newPage();
let sitekey = null;
const enterprisePayload = {};
const targetUrl = 'https://example.com';
await page.goto(targetUrl, { timeout: 60000 });
await page.waitForTimeout(3000);
const recaptchaDivs = await page.$$('.g-recaptcha');
for (const div of recaptchaDivs) {
const attrs = ['data-sitekey', 'data-s', 'data-cdata', 'data-type', 'data-context'];
for (const attr of attrs) {
const val = await div.getAttribute(attr);
if (val) {
const key = attr.replace('data-', '');
if (key === 'sitekey') {
sitekey = val;
} else {
enterprisePayload[key] = val;
}
}
}
}
const inlineScripts = await page.$$eval("script:not([src])", (scripts) =>
scripts.map((s) => s.textContent)
);
const pattern = /grecaptcha\.enterprise\.render\([^,]+,\s*\{(.*?)\}/s;
for (const script of inlineScripts) {
const match = script.match(pattern);
if (match) {
const obj = match[1];
const keyValuePattern = /(\w+)\s*:\s*['"]([^'"]+)['"]/g;
let keyValueMatch;
while ((keyValueMatch = keyValuePattern.exec(obj)) !== null) {
const key = keyValueMatch[1];
const val = keyValueMatch[2];
if (key === 'sitekey') {
sitekey = val;
} else {
enterprisePayload[key] = val;
}
}
break;
}
}
console.log(`sitekey: ${sitekey}`);
console.log("enterprisePayload:");
for (const [key, value] of Object.entries(enterprisePayload)) {
console.log(` ${key}: ${value}`);
}
await browser.close();
})();
Show Code
import asyncio
import re
from playwright.async_api import async_playwright
async def extract_recaptcha_v2_enterprise(url):
async with async_playwright() as p:
browser = await p.chromium.launch(headless=False)
context = await browser.new_context()
page = await context.new_page()
sitekey = None
enterprise_payload = {}
await page.goto(url, timeout=60000)
await page.wait_for_timeout(3000)
recaptcha_divs = await page.query_selector_all(".g-recaptcha")
for div in recaptcha_divs:
attrs = ["data-sitekey", "data-s", "data-cdata", "data-type", "data-context"]
for attr in attrs:
val = await div.get_attribute(attr)
if val:
key = attr.replace("data-", "")
if key == "sitekey":
sitekey = val
else:
enterprise_payload[key] = val
inline_scripts = await page.locator("script:not([src])").all_text_contents()
pattern = re.compile(r"grecaptcha\.enterprise\.render\([^,]+,\s*\{(.*?)\}", re.DOTALL)
for script in inline_scripts:
match = pattern.search(script)
if match:
obj = match.group(1)
for pair in re.finditer(r"(\w+)\s*:\s*['\"]([^'\"]+)['\"]", obj):
key = pair.group(1)
val = pair.group(2)
if key == "sitekey":
sitekey = val
else:
enterprise_payload[key] = val
break
await browser.close()
print(f"sitekey: {sitekey}")
print("enterprisePayload:")
for k, v in enterprise_payload.items():
print(f" {k}: {v}")
asyncio.run(extract_recaptcha_v2_enterprise("https://example.com"))
Show Code
using System;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Playwright;
using System.Collections.Generic;
class Program
{
public static async Task Main(string[] args)
{
await ExtractRecaptchaV2Enterprise("https://example.com");
}
public static async Task ExtractRecaptchaV2Enterprise(string url)
{
using var playwright = await Playwright.CreateAsync();
var browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false });
var context = await browser.NewContextAsync();
var page = await context.NewPageAsync();
string sitekey = null;
var enterprisePayload = new Dictionary<string, string>();
await page.GotoAsync(url, new PageGotoOptions { Timeout = 60000 });
await page.WaitForTimeoutAsync(3000);
var recaptchaDivs = await page.QuerySelectorAllAsync(".g-recaptcha");
foreach (var div in recaptchaDivs)
{
var sitekeyAttr = await div.GetAttributeAsync("data-sitekey");
if (!string.IsNullOrEmpty(sitekeyAttr))
sitekey = sitekeyAttr;
var attributes = new[] { "data-s", "data-cdata", "data-type", "data-context" };
foreach (var attr in attributes)
{
var value = await div.GetAttributeAsync(attr);
if (!string.IsNullOrEmpty(value))
{
enterprisePayload[attr.Replace("data-", "")] = value;
}
}
}
var scripts = await page.Locator("script:not([src])").AllTextContentsAsync();
var pattern = new Regex(@"grecaptcha\.enterprise\.render\([^,]+,\s*\{(.*?)\}",
RegexOptions.Singleline);
foreach (var script in scripts)
{
var match = pattern.Match(script);
if (match.Success)
{
var obj = match.Groups[1].Value;
var keyMatches = Regex.Matches(obj, @"(\w+)\s*:\s*['""]([^'""]+)['""]");
foreach (Match m in keyMatches)
{
var key = m.Groups[1].Value.Trim();
var val = m.Groups[2].Value.Trim();
if (key == "sitekey")
sitekey = val;
else
enterprisePayload[key] = val;
}
break;
}
}
Console.WriteLine($"Sitekey: {sitekey}");
Console.WriteLine("Enterprise Payload:");
foreach (var kv in enterprisePayload)
{
Console.WriteLine($" {kv.Key}: {kv.Value}");
}
await browser.CloseAsync();
}
}
Use SDK Library
- JavaScript
- Python
- C#
// https://github.com/ZennoLab/capmonstercloud-client-js
import { CapMonsterCloudClientFactory, ClientOptions, RecaptchaV2EnterpriseRequest, /*RecaptchaV2EnterpriseRequest*/ } from '@zennolab_com/capmonstercloud-client';
document.addEventListener('DOMContentLoaded', async () => {
const cmcClient = CapMonsterCloudClientFactory.Create(new ClientOptions({ clientKey: '<your capmonster.cloud API key>' }));
console.log(await cmcClient.getBalance());
const recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseRequest({
websiteURL: 'https://mydomain.com/page-with-recaptcha-enterprise',
websiteKey: '6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd',
enterprisePayload: {
s: 'SOME_ADDITIONAL_TOKEN',
},
});
// const recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseRequest({
// websiteURL: 'https://mydomain.com/page-with-recaptcha-enterprise',
// websiteKey: '6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd',
// enterprisePayload: {
// s: 'SOME_ADDITIONAL_TOKEN',
// },
// proxyType: 'http',
// proxyAddress: '8.8.8.8',
// proxyPort: 8080,
// proxyLogin: 'proxyLoginHere',
// proxyPassword: 'proxyPasswordHere',
// userAgent: 'userAgentPlaceholder',
// });
console.log(await cmcClient.Solve(recaptchaV2EnterpriseRequest));
});
# https://github.com/ZennoLab/capmonstercloud-client-python
# RecaptchaV2Enterprise
import asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import RecaptchaV2EnterpriseRequest
client_options = ClientOptions(api_key="your_api_key") # Replace with your CapMonster Cloud API key
cap_monster_client = CapMonsterClient(options=client_options)
recaptcha2request = RecaptchaV2EnterpriseRequest(
websiteUrl="https://example.com", # Website with the captcha
websiteKey="6Lf26sUnAAAAAIKLuWNYgRsFUfmI-3Lex3xT5N-s", # Replace with your websiteKey
enterprisePayload={
"s": "SOME_ADDITIONAL_TOKEN"
}
)
async def solve_captcha():
return await cap_monster_client.solve_captcha(recaptcha2request)
responses = asyncio.run(solve_captcha())
print(responses)
# ReCaptchaV2Enterprise:
import asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import RecaptchaV2EnterpriseRequest
client_options = ClientOptions(api_key="your_api_key") # Replace with your CapMonster Cloud API key
cap_monster_client = CapMonsterClient(options=client_options)
recaptcha2request = RecaptchaV2EnterpriseRequest(
websiteUrl="https://example.com", # Website with the captcha
websiteKey="6Lf26sUnAAAAAIKLuWNYgRsFUfmI-3Lex3xT5N-s", # Replace with your websiteKey
enterprisePayload={
"s": "SOME_ADDITIONAL_TOKEN"
},
proxy_type="http", # Proxy type (http, https, socks5)
proxy_address="8.8.8.8",
proxy_port=8080,
proxy_login="proxyLoginHere",
proxy_password="proxyPasswordHere"
)
async def solve_captcha():
return await cap_monster_client.solve_captcha(recaptcha2request)
responses = asyncio.run(solve_captcha())
print(responses)
// https://github.com/ZennoLab/capmonstercloud-client-dotnet
// RecaptchaV2Enterprise
using Zennolab.CapMonsterCloud.Requests;
using Zennolab.CapMonsterCloud;
class Program
{
static async Task Main(string[] args)
{
var clientOptions = new ClientOptions
{
ClientKey = "your_api_key" // Replace with your CapMonster Cloud API key
};
var cmCloudClient = CapMonsterCloudClientFactory.Create(clientOptions);
var recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseRequest
{
WebsiteUrl = "https://example.com", // Website with the captcha
WebsiteKey = "6Lf26sUnAAAAAIKLuWNYgRsFUfmI-3Lex3xT5N-s", // Replace with your website key
EnterprisePayload = "{\"s\":\"SOME_ADDITIONAL_TOKEN\"}"
};
var recaptchaV2EnterpriseResult = await cmCloudClient.SolveAsync(recaptchaV2EnterpriseRequest);
Console.WriteLine("Captcha Solution: " + recaptchaV2EnterpriseResult.Solution.Value);
}
}
// ReCaptchaV2Enterprise:
using Zennolab.CapMonsterCloud.Requests;
using Zennolab.CapMonsterCloud;
class Program
{
static async Task Main(string[] args)
{
var clientOptions = new ClientOptions
{
ClientKey = "your_api_key" // Replace with your CapMonster Cloud API key
};
var cmCloudClient = CapMonsterCloudClientFactory.Create(clientOptions);
var recaptchaV2EnterpriseRequest = new RecaptchaV2EnterpriseRequest
{
WebsiteUrl = "https://example.com", // Website with the captcha
WebsiteKey = "6Lf26sUnAAAAAIKLuWNYgRsFUfmI-3Lex3xT5N-s", // Replace with your website key
EnterprisePayload = "{\"s\":\"SOME_ADDITIONAL_TOKEN\"}",
ProxyType = ProxyType.Http,
ProxyAddress = "8.8.8.8",
ProxyPort = 8080,
ProxyLogin = "proxyLoginHere",
ProxyPassword = "proxyPasswordHere"
};
var recaptchaV2EnterpriseResult = await cmCloudClient.SolveAsync(recaptchaV2EnterpriseRequest);
Console.WriteLine("Captcha Solution: " + recaptchaV2EnterpriseResult.Solution.Value);
}
}