MTCaptcha

CapMonster Cloud 默认通过内置代理工作——这些代理已包含在费用内。仅当网站不接受令牌或对内置服务的访问受限时,才需要指定您自己的代理。
如果代理按 IP 授权,请将地址 65.21.190.34 加入白名单。
请求参数
type<string>requiredMTCaptchaTask
websiteURL<string>required进行验证码识别的网页地址。
websiteKey<string>requiredMTCaptcha 密钥,在请求参数中以 sk 传递(请参阅下方查找方法示例)。
大致格式如下:MTPublic-abCDEFJAB
pageAction<string>optional参数 action 在请求中以 act 传递,并在令牌验证时显示。仅当其值不同于默认值 %24 时,才需要在请求中指定。
html 示例:
<script>
var mtcaptchaConfig = {
"sitekey": "MTPublic-abCDEFJAB",
"action": "login"
};
</script>
isInvisible<bool>optional如果验证码为隐形验证码,即具有隐藏的确认字段,则为 true。检测到疑似机器人时会触发额外验证。
userAgent<string>optional浏览器 User-Agent。请使用 CapMonster Cloud 当前支持的值:userAgentPlaceholder
可通过以下地址获取最新值:https://capmonster.cloud/api/useragent/actual。
proxyType<string>optionalhttp - 常规 http/https 代理;
https - 仅当 "http" 无效时使用(某些自定义代理需要);
socks4 - socks4 代理;
socks5 - socks5 代理。
proxyAddress<string>optional代理的 IPv4/IPv6 地址。禁止以下使用方式:
- 使用透明代理(可暴露客户端 IP);
- 使用本地机器上的代理。
proxyPort<integer>optional代理端口。
proxyLogin<string>optional代理服务器登录用户名。
proxyPassword<string>optional代理服务器登录密码。
创建任务的方法
- MTCaptchaTask(无代理)
- MTCaptchaTask(使用代理时)
https://api.capmonster.cloud/createTask
请求示例
{
"clientKey": "API_KEY",
"task":
{
"type": "MTCaptchaTask",
"websiteURL": "https://yourwebsite.com/page-with-mtcaptcha",
"websiteKey": "your-website-key",
"isInvisible": false,
"pageAction": "your-page-action"
}
}
响应示例
{
"errorId":0,
"taskId":407533077
}
https://api.capmonster.cloud/createTask
请求示例
{
"clientKey": "API_KEY",
"task":
{
"type": "MTCaptchaTask",
"websiteURL": "https://yourwebsite.com/page-with-mtcaptcha",
"websiteKey": "your-website-key",
"isInvisible": false,
"pageAction": "your-page-action",
"proxyType": "your-proxy-type",
"proxyAddress": "your-proxy-address",
"proxyPort": 1234,
"proxyLogin": "your-proxy-login",
"proxyPassword": "your-proxy-password"
}
}
响应示例
{
"errorId":0,
"taskId":407533077
}
获取任务结果的方法
使用 getTaskResult 方法获取 MTCaptcha 验证码的解决结果。
https://api.capmonster.cloud/getTaskResult
请求示例
{
"clientKey": "API_KEY",
"taskId": 407533077
}
响应示例
{
"errorId": 0,
"errorCode": null,
"errorDescription": null,
"solution": {
"token": "v1(155506dc,c8c2e356,MTPublic-abCDEFJAB,70f03532a53...5FSDA**)"
},
"status": "ready"
}
如何查找验证码参数
websiteKey
在开发者工具的 Network 标签中可以找到此参数。
查找类似以 getchallenge.json 开头的请求 — 参数 sk 对应 websiteKey。

pageAction
该请求中也包含参数 pageAction,其值通过 act 传递。
默认值为 %24;若值不同(如 ..&act=login&...),请在创建任务时传入。

使用 SDK 库
- JavaScript / TypeScript
- Python
- C#
显示代码(浏览器)
// https://github.com/CapMonsterCloud/capmonster-nodejs-captcha-solver
import {
CapMonsterCloudClientFactory,
ClientOptions,
MTCaptchaRequest
} from "@zennolab_com/capmonstercloud-client";
document.addEventListener("DOMContentLoaded", async () => {
const API_KEY = "YOUR_API_KEY"; // 请指定您的 CapMonster Cloud API 密钥
const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY })
);
// 不使用代理的基础示例
// CapMonster Cloud 会自动使用自己的代理
let mtcaptchaRequest = new MTCaptchaRequest({
websiteURL: "https://yourwebsite.com/page-with-mtcaptcha",
websiteKey: "your-website-key",
isInvisible: false,
pageAction: "login",
});
// 使用您自己的代理的示例
// 如果您想使用自己的代理,请取消注释此代码块
/*
const proxy = {
proxyType: "http",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password",
};
mtcaptchaRequest = new MTCaptchaRequest({
websiteURL: "https://yourwebsite.com/page-with-mtcaptcha",
websiteKey: "your-website-key",
isInvisible: false,
pageAction: "login",
proxy,
userAgent: "userAgentPlaceholder",
});
*/
// 如有需要,可以检查余额
const balance = await client.getBalance();
console.log("Balance:", balance);
const result = await client.Solve(mtcaptchaRequest);
console.log("Solution:", result.solution);
});
显示代码(Node.js)
// https://github.com/CapMonsterCloud/capmonster-nodejs-captcha-solver
const {
CapMonsterCloudClientFactory,
ClientOptions,
MTCaptchaRequest,
} = require("@zennolab_com/capmonstercloud-client");
const API_KEY = "YOUR_API_KEY"; // 请指定您的 CapMonster Cloud API 密钥
async function solveMTCaptcha() {
const client = CapMonsterCloudClientFactory.Create(
new ClientOptions({ clientKey: API_KEY }),
);
// 不使用代理的基础示例
// CapMonster Cloud 会自动使用自己的代理
let mtcaptchaRequest = new MTCaptchaRequest({
websiteURL: "https://yourwebsite.com/page-with-mtcaptcha",
websiteKey: "your-website-key",
isInvisible: false,
pageAction: "login",
});
// 使用您自己的代理的示例
// 如果您想使用自己的代理,请取消注释此代码块
/*
const proxy = {
proxyType: "http",
proxyAddress: "123.45.67.89",
proxyPort: 8080,
proxyLogin: "username",
proxyPassword: "password",
};
mtcaptchaRequest = new MTCaptchaRequest({
websiteURL: "https://yourwebsite.com/page-with-mtcaptcha",
websiteKey: "your-website-key",
isInvisible: false,
pageAction: "login",
proxy,
userAgent: "userAgentPlaceholder",
});
*/
// 如有需要,可以检查余额
const balance = await client.getBalance();
console.log("Balance:", balance);
const result = await client.Solve(mtcaptchaRequest);
console.log("Solution:", result.solution);
}
solveMTCaptcha().catch(console.error);
显示代码
# https://github.com/CapMonsterCloud/capmonster-python-captcha-solver
import asyncio
from capmonstercloudclient import CapMonsterClient, ClientOptions
from capmonstercloudclient.requests import MTCaptchaRequest
# 如果您计划使用自己的代理,请导入 ProxyInfo
from capmonstercloudclient.requests.proxy_info import ProxyInfo
API_KEY = "YOUR_API_KEY" # 请指定您的 CapMonster Cloud API 密钥
async def solve_mtcaptcha():
client = CapMonsterClient(
options=ClientOptions(api_key=API_KEY)
)
# 不使用代理的基础示例
# CapMonster Cloud 会自动使用自己的代理
mtcaptcha_request = MTCaptchaRequest(
websiteUrl="https://yourwebsite.com/page-with-mtcaptcha",
websiteKey="your-website-key",
isInvisible=False,
pageAction="login",
)
# 使用您自己的代理的示例
# 如果您想使用自己的代理,请取消注释此代码块
"""
proxy = ProxyInfo(
proxyType="http",
proxyAddress="123.45.67.89",
proxyPort=8080,
proxyLogin="username",
proxyPassword="password",
)
mtcaptcha_request = MTCaptchaRequest(
websiteUrl="https://yourwebsite.com/page-with-mtcaptcha",
websiteKey="your-website-key",
isInvisible=False,
pageAction="login",
proxy=proxy,
userAgent="userAgentPlaceholder",
)
"""
# 如有需要,可以检查余额
balance = await client.get_balance()
print("Balance:", balance)
result = await client.solve_captcha(mtcaptcha_request)
print("Solution:", result)
asyncio.run(solve_mtcaptcha())
显示代码
// https://github.com/CapMonsterCloud/capmonster-dotnet-captcha-solver
using System;
using System.Threading.Tasks;
using Zennolab.CapMonsterCloud;
using Zennolab.CapMonsterCloud.Requests;
class Program
{
static async Task Main(string[] args)
{
// 请指定您的 CapMonster Cloud API 密钥
var clientOptions = new ClientOptions
{
ClientKey = "YOUR_API_KEY"
};
var cmCloudClient = CapMonsterCloudClientFactory.Create(clientOptions);
// 不使用代理的基础示例
// CapMonster Cloud 会自动使用自己的代理
var mtcaptchaRequest = new MTCaptchaTaskRequest
{
WebsiteUrl = "https://yourwebsite.com/page-with-mtcaptcha",
WebsiteKey = "your-website-key",
Invisible = false,
PageAction = "login",
UserAgent = "userAgentPlaceholder"
};
// 使用您自己的代理的示例
// 如果您想使用自己的代理,请取消注释此代码块
/*
mtcaptchaRequest = new MTCaptchaTaskRequest
{
WebsiteUrl = "https://yourwebsite.com/page-with-mtcaptcha",
WebsiteKey = "your-website-key",
Invisible = false,
PageAction = "login",
UserAgent = "userAgentPlaceholder",
Proxy = new ProxyContainer(
"123.45.67.89",
8080,
ProxyType.Http,
"username",
"password"
)
};
*/
// 如有需要,可以检查余额
var balance = await cmCloudClient.GetBalanceAsync();
Console.WriteLine("Balance: " + balance);
var mtcaptchaResult = await cmCloudClient.SolveAsync(mtcaptchaRequest);
Console.WriteLine("Solution: " + mtcaptchaResult.Solution.Value);
}
}
