指南
任务(令牌)
BotDeflector

BotDeflector: 解决 BotDeflector

提示

使用 createTask 方法创建任务,并使用 getTaskResult 方法获取结果。

我们支持的任务类型 type

  • AntiBotdeflectorTaskProxyLess 此任务类型不需要您自己的代理。

创建任务

使用 createTask 方法创建识别任务。

任务对象结构

属性类型必需描述
typeStringRequiredAntiBotdeflectorTaskProxyLess
websiteURLStringRequired当前网站主页的 URL
domainStringRequired/pow/get 或者 icon/get 接口使用的域名,示例:botdeflector.eu
flowTokenStringRequired在网站上可能叫 botDeflectorJwtToken,示例:eyJhbGciOiJ...
注意

domain 参数和 websiteURL 参数不一定是同一个域名,注意区分

请求示例

POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
 
{
    "clientKey": "YOUR_API_KEY",
    "task": {
        "type": "AntiBotdeflectorTaskProxyLess", // Required
        "websiteURL": "https://exaple.com/",     // Required
        "domain":"exaple.com",                   // Required
        "flowToken":"eyJhbGciOiJI1...",          // Required
    }
}

在您向我们提交任务后,如果成功,您将在响应中收到一个 ‘taskId’。如果您未收到任务 ID,请查阅 errorCode: 错误列表

响应示例

{
    "errorId": 0,
    "errorCode": "",
    "errorDescription": "",
    "taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}

获取结果

获取 taskId 后,您需要提交该 taskId 以检索解决方案。响应结构在 getTaskResult 中有说明。

根据系统负载情况,您将在 1s30s 的时间内获得结果。

请求示例

POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json
 
{
    "clientKey": "YOUR_API_KEY",
    "taskId": "61138bb6-19fb-11ec-a9c8-0242ac110006"
}

响应示例

{
  "errorId": 0,
  "taskId": "646825ef-9547-4a29-9a05-50a6265f9d8a",
  "status": "ready",
  "solution": {
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhY2NvdW50SWQiOiI1ZmMyOGEwMi04Z..."
  }
}

使用 SDK 请求

# pip install --upgrade capsolver
# export CAPSOLVER_API_KEY='...'
 
import capsolver
 
# capsolver.api_key = "..."
solution = capsolver.solve({
    "type": "AntiBotdeflectorTaskProxyLess",
    "websiteURL": "https://exaple.com/",
    "domain":"exaple.com",
    "flowToken":"eyJhbGciOiJI1...",
})

示例代码

# pip install requests
import requests
import time
 
api_key = "YOUR_API_KEY"  # 您的capsolver api密钥
 
def capsolver():
payload = {
    "clientKey": api_key,
    "task": {
        "type": "AntiBotdeflectorTaskProxyLess",
        "websiteURL": "https://exaple.com/",
        "domain":"exaple.com",
        "flowToken":"eyJhbGciOiJI1...",
    }
}
res = requests.post("https://api.capsolver.com/createTask", json=payload)
resp = res.json()
task_id = resp.get("taskId")
if not task_id:
    print("Failed to create task:", res.text)
    return
print(f"Got taskId: {task_id} / 正在获取结果...")
 
while True:
    time.sleep(1)  # 延迟
    payload = {"clientKey": api_key, "taskId": task_id}
    res = requests.post("https://api.capsolver.com/getTaskResult", json=payload)
    resp = res.json()
    status = resp.get("status")
    if status == "ready":
        return resp.get("solution", {}).get("token")
    if status == "failed" or resp.get("errorId"):
        print("解决失败!响应:", res.text)
        return
 
token = capsolver()
print(token)