跳转到主要内容
获取令牌时遇到问题吗
联系支持

RecaptchaV2Task

该对象包含 Google ReCaptcha2 解决任务的数据。为确保解决此类验证码的普遍性,您需要使用在自动填写目标网站表单时使用的所有数据,包括代理、浏览器用户代理和 cookies。这将有助于避免在 Google 更改其验证码代码时出现任何问题。

相比于普通的图像验证码,此类验证码可能需要更长时间来解决,但通过我们发送给您的 g-captcha-response 值,在解决您的 ReCaptcha2 后的下一个 60 秒内仍然有效,可以弥补这一问题。

更多相关内容,请访问我们的博客
警告注意!

如果代理由 IP 授权,请确保将 116.203.55.208 添加到白名单中。

对象结构

type<string>required

RecaptchaV2Task


websiteURL<string>required

带有验证码的网页地址。


websiteKey<string>required

ReCaptcha 网站密钥。
<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>optional

http - 普通的 http/https 代理;
https - 仅在 "http" 不起作用时尝试(某些自定义代理服务器要求);
socks4 - socks4 代理;
socks5 - socks5 代理。


proxyAddress<string>optional

代理 IP 地址 IPv4/IPv6。不允许:

  • 使用主机名;
  • 使用透明代理(其中客户端 IP 可见);
  • 使用来自本地网络的代理。


proxyPort<integer>optional

代理端口。


proxyLogin<string>optional

代理登录。


proxyPassword<string>optional

代理密码。

创建任务方法

POST
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
}

获取任务结果方法

使用getTaskResult方法请求 ReCaptcha2 的答案。您将在服务工作负载下的10到80秒内收到响应。

POST
https://api.capmonster.cloud/getTaskResult

要求

{
"clientKey":"API_KEY",
"taskId": 407533072
}

回应

{
"errorId":0,
"status":"ready",
"solution": {
"gRecaptchaResponse":"3AHJ_VuvYIBNBW5yyv0zRYJ75VkOKvhKj9_xGBJKnQimF72rfoq3Iy-DyGHMwLAo6a3"
}
}

属性类型描述
gRecaptchaResponseString应插入到 Recaptcha2 提交表单中的哈希值,格式如 <textarea id="g-recaptcha-response" ..></textarea>。长度为500到2190字节。

使用 SDK 库

// 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));
});
更多相关内容,请访问我们的博客