RecaptchaV2Task
该对象包含 Google ReCaptcha2 解决任务的数据。为确保解决此类验证码的普遍性,您需要使用在自动填写目标网站表单时使用的所有数据,包括代理、浏览器用户代理和 cookies。这将有助于避免在 Google 更改其验证码代码时出现任何问题。
相比于普通的图像验证码,此类验证码可能需要更长时间来解决,但通过我们发送给您的 g-captcha-response 值,在解决您的 ReCaptcha2 后的下一个 60 秒内仍然有效,可以弥补这一问题。
如果代理由 IP 授权,请确保将 116.203.55.208 添加到白名单中。
对象结构
type
<string>requiredRecaptchaV2Task
websiteURL
<string>required带有验证码的网页地址。
websiteKey
<string>requiredReCaptcha 网站密钥。<div class="g-recaptcha" data-sitekey="THIS_ONE"></div>
recaptchaDataSValue
<string>optional某些自定义实现可能包含 ReCaptcha2 div 中的额外 "data-s" 参数,实际上是一次性令牌,每次解决 ReCaptcha2 都必须获取。<div class="g-recaptcha" data-sitekey="some sitekey" data-s="THIS_ONE"></div>
userAgent
<string>optional用于仿真的浏览器用户代理。必须使用现代浏览器的签名,否则 Google 将要求您 "更新您的浏览器"。
cookies
<string>optional额外的 Cookie,我们在与目标页面或谷歌的交互过程中必须使用
格式:cookiename1=cookievalue1; cookiename2=cookievalue2
isInvisible
<bool>optional"true" 如果验证码是隐形的,即没有确认复选框,而是有一个隐藏字段。如果怀疑是机器人,则进行额外检查。
proxyType
<string>optionalhttp - 普通的 http/https 代理;
https - 仅在 "http" 不起作用时尝试(某些自定义代理服务器要求);
socks4 - socks4 代理;
socks5 - socks5 代理。
proxyAddress
<string>optional代理 IP 地址 IPv4/IPv6。不允许:
- 使用主机名;
- 使用透明代理(其中客户端 IP 可见);
- 使用来自本地网络的代理。
proxyPort
<integer>optional代理端口。
proxyLogin
<string>optional代理登录。
proxyPassword
<string>optional代理密码。
创建任务方法
- RecaptchaV2Task (无代理)
- RecaptchaV2Task (使用代理)
https://api.capmonster.cloud/createTask
要求
{
"clientKey":"API_KEY",
"task": {
"type":"RecaptchaV2Task",
"websiteURL":"https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
"websiteKey":"6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd"
}
}
回应
{
"errorId":0,
"taskId":407533072
}
https://api.capmonster.cloud/createTask
要求
{
"clientKey":"API_KEY",
"task": {
"type":"RecaptchaV2Task",
"websiteURL":"https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high",
"websiteKey":"6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd",
"proxyType":"http",
"proxyAddress":"8.8.8.8",
"proxyPort":8080,
"proxyLogin":"proxyLoginHere",
"proxyPassword":"proxyPasswordHere",
"userAgent":"userAgentPlaceholder"
}
}
回应
{
"errorId":0,
"taskId":407533072
}
获取任务结果方法
使用getTaskResult方法请求 ReCaptcha2 的答案。您将在服务工作负载下的10到80秒内收到响应。
https://api.capmonster.cloud/getTaskResult
要求
{
"clientKey":"API_KEY",
"taskId": 407533072
}
回应
{
"errorId":0,
"status":"ready",
"solution": {
"gRecaptchaResponse":"3AHJ_VuvYIBNBW5yyv0zRYJ75VkOKvhKj9_xGBJKnQimF72rfoq3Iy-DyGHMwLAo6a3"
}
}
属性 | 类型 | 描述 |
---|---|---|
gRecaptchaResponse | String | 应插入到 Recaptcha2 提交表单中的哈希值,格式如 <textarea id="g-recaptcha-response" ..></textarea> 。长度为500到2190字节。 |
使用 SDK 库
- JavaScript
- Python
- C#
// https://github.com/ZennoLab/capmonstercloud-client-js
import { CapMonsterCloudClientFactory, ClientOptions, RecaptchaV2Request, /*RecaptchaV2Request*/ } 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 recaptchaV2Request = new RecaptchaV2Request({
websiteURL: 'https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high',
websiteKey: '6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd',
});
// const recaptchaV2Request = new RecaptchaV2Request({
// websiteURL: 'https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high',
// websiteKey: '6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd',
// proxyType: 'http',
// proxyAddress: '8.8.8.8',
// proxyPort: 8080,
// proxyLogin: 'proxyLoginHere',
// proxyPassword: 'proxyPasswordHere',
// userAgent: 'userAgentPlaceholder',
// });
console.log(await cmcClient.Solve(recaptchaV2Request));
});
# https://github.com/ZennoLab/capmonstercloud-client-python
# ReСaptchaV2:
import asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import RecaptchaV2Request
client_options = ClientOptions(api_key="your_api_key") # Replace with your CapMonster Cloud API key
cap_monster_client = CapMonsterClient(options=client_options)
recaptcha2request = RecaptchaV2Request(
websiteUrl="https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high", # URL with captcha
websiteKey="6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd" # Replace with the correct website key
)
async def solve_captcha():
return await cap_monster_client.solve_captcha(recaptcha2request)
responses = asyncio.run(solve_captcha())
print(responses)
# ReСaptchaV2:
import asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import RecaptchaV2Request
client_options = ClientOptions(api_key="your_api_key") # Replace with your CapMonster Cloud API key
cap_monster_client = CapMonsterClient(options=client_options)
recaptcha2_request = RecaptchaV2Request(
websiteUrl="https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high", # URL with captcha
websiteKey="6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd", # ReCaptcha v2 site key
proxyType="http",
proxyAddress="8.8.8.8",
proxyPort=8080,
proxyLogin="proxyLoginHere",
proxyPassword="proxyPasswordHere",
userAgent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36" # Use the current userAgent
)
async def solve_captcha():
return await cap_monster_client.solve_captcha(recaptcha2_request)
response = asyncio.run(solve_captcha())
print(response)
// https://github.com/ZennoLab/capmonstercloud-client-dotnet
// ReСaptchaV2:
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 recaptchaV2Request = new RecaptchaV2Request
{
WebsiteUrl = "https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high", // URL with captcha
WebsiteKey = "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd", // Replace with the correct website key
};
var recaptchaV2Result = await cmCloudClient.SolveAsync(recaptchaV2Request);
Console.WriteLine("Captcha Solution: " + recaptchaV2Result.Solution.Value);
}
}
// ReСaptchaV2:
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 recaptchaV2Request = new RecaptchaV2Request
{
WebsiteUrl = "https://lessons.zennolab.com/captchas/recaptcha/v2_simple.php?level=high", // URL with captcha
WebsiteKey = "6Lcg7CMUAAAAANphynKgn9YAgA4tQ2KI_iqRyTwd", // Replace with the correct website key
ProxyType = ProxyType.Http,
ProxyAddress = "8.8.8.8",
ProxyPort = 8080,
ProxyLogin = "proxyLoginHere",
ProxyPassword = "proxyPasswordHere"
};
var recaptchaV2Result = await cmCloudClient.SolveAsync(recaptchaV2Request);
Console.WriteLine("Captcha Solution: " + recaptchaV2Result.Solution.Value);
}
}