MtCaptcha 协议接口
TIP
⚠️ 通过 createTask 创建任务, 然后通过 getTaskResult 获取识别结果
任务类型type
如下
MtCaptchaTask
必须传入代理MtCaptchaTaskProxyLess
无需代理或已内置代理
创建任务
通过 createTask 创建任务
参数结构
属性 | 类型 | Required | 说明 |
---|---|---|---|
type | String | Yes | MtCaptchaTask MtCaptchaTaskProxyLess |
websiteURL | String | Yes | Address of a webpage with mtcaptcha |
websiteKey | String | Yes | sk=MTPublic-xxx public key |
proxy | String | No | 学习如何使用代理 |
请求示例
json
POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"task": {
"type": "MtCaptchaTask",
"websiteURL": "https://www.mtcaptcha.com/demo",
"websiteKey": "MTPublic-tqNCRE0GS",
"proxy": "http:ip:port:user:pass" // socks5:ip:port:user:pass
}
}
响应示例
json
{
"errorId": 0,
"errorCode": "",
"errorDescription": "",
"taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006" // 请记录此ID
}
获取结果
使用 getTaskResult 方法获取识别结果
根据系统负载,您将在 1s
到 20s
的时间间隔内得到结果
请求示例
json
POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json
{
"clientKey": "YOUR_API_KEY",
"taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}
响应示例
json
{
"errorId": 0,
"taskId": "646825ef-9547-4a29-9a05-50a6265f9d8a",
"status": "ready",
"solution": {
"token": "v1(aba1cefe,ca8fb4ea,MTPublic-FYhK03Mlj,c3281f68b7a14b8ba64d7a0db167c3c7,5eszjJbkVCqGVEIUNhFmLMLRh_XzWJgxvVRxBU8pg4O5oynOCNsXZlJF8yRXrWeSGnFhgFGlam1TioUxVsWeIMPdLvkpnivgId2AKiJZ7OMEpJt-e_0d_2tGfN_0p1hKCLxXhvzlklHNcMXju3j8fS0VV4C4fnTi5v6otUAWEEwFNVuDj30LJXZizD2_yl3ThZm3VHkgrxcFFr-WUD8Mpq1YY0bbh-E4DT8G14qBYRN0odfNbZAyKjF919kRd2rPqiLjP2uw4h0WcUZ2c1BwWkWHoZ5N7M09Pd7cOA8wz4kP_2JN_hQIYWnjxIpxBqXzdKtsgCsXwtq4lu1weGgfuQ**)"
}
}
使用 SDK 请求
python
#pip install --upgrade capsolver
#export CAPSOLVER_API_KEY='...'
import capsolver
# capsolver.api_key = "..."
solution = capsolver.solve({
"type": "MtCaptchaTask",
"websiteURL": "https://www.mtcaptcha.com/demo",
"websiteKey": "MTPublic-tqNCRE0GS",
"proxy":"ip:port:username:port",
})
golang
package main
import (
"fmt"
capsolver_go "github.com/capsolver/capsolver-go"
"log"
)
func main() {
// first you need to install sdk
//go get github.com/capsolver/capsolver-go
//export CAPSOLVER_API_KEY='...' or
//capSolver := CapSolver{apiKey:"..."}
capSolver := capsolver_go.CapSolver{}
solution, err := capSolver.Solve(map[string]any{
"type": "MtCaptchaTask",
"websiteURL": "https://www.mtcaptcha.com/demo",
"websiteKey": "MTPublic-tqNCRE0GS",
"proxy":"ip:port:username:port",
})
if err != nil {
log.Fatal(err)
return
}
fmt.Println(solution)
}