指南
任务(令牌)
Friendlycaptcha

FriendlyCaptcha:解决 Friendly Captcha

TIP

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

我们支持的任务类型 types:

  • FriendlyCaptchaTaskProxyless

创建任务

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

任务对象结构

属性类型必填描述
typeString必填FriendlyCaptchaTaskProxyless
websiteURLString必填出现 Friendly Captcha 的页面地址
websiteKeyString必填网站密钥

请求示例

POST https://api.capsolver.com/createTask
Host: api.capsolver.com
Content-Type: application/json
{
  "clientKey": "YOUR_API_KEY",
  "task": {
    "type": "FriendlyCaptchaTaskProxyless",
    "websiteURL": "https://www.yourtarget.com/",
    "websiteKey": "FBTMEAFCK477GTRU"
  }
}

将任务提交给我们后,如果成功,您应该在响应中收到一个“taskId”。 如果您未收到任务 ID,请阅读 errorCode:错误代码完整列表。

响应示例

{
    "errorId": 0,
    "errorDescription": "",
    "status": "idle",
    "taskId": "0a9b8fad-66e5-4271-96a3-bee8751cfb83"
}

获取结果

拥有 taskId 后,您需要提交 taskId 以检索解决方案。响应结构在 getTaskResult 中解释。

请求示例

POST https://api.capsolver.com/getTaskResult
Host: api.capsolver.com
Content-Type: application/json
 
{
    "clientKey": "YOUR_API_KEY",
    "taskId": "0a9b8fad-66e5-4271-96a3-bee8751cfb83"
}

响应示例

{
    "errorId": 0,
    "taskId": "0a9b8fad-66e5-4271-96a3-bee8751cfb83",
    "status": "ready",
    "solution": {
        "token": "72b43902cd1457f6880dd3735c50070d.Z0+9+Hcx7KGSmHd1AQwtjQ..."
    }
}

示例代码

# pip install requests
import requests
import time
 
# TODO: set your config
api_key = "YOUR_API_KEY"  # your api key of capsolver
site_key = "FBTMEAFCK477GTRU"  # site key of your target site
site_url = "https://www.yourtarget.com"  # page url of your target site
 
 
def capsolver():
    payload = {
        "clientKey": api_key,
        "task": {
            "type": 'FriendlyCaptchaTaskProxyless',
            "websiteKey": site_key,
            "websiteURL": site_url
        }
    }
    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} / Getting result...")
 
    while True:
        time.sleep(1)  # delay
        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("Solve failed! response:", res.text)
            return
 
 
token = capsolver()
print(token)