Hướng dẫn
Nhiệm vụ (Token)
Friendlycaptcha

FriendlyCaptcha: giải Friendly Captcha

TIP

Tạo tác vụ bằng phương thức createTask và nhận kết quả bằng phương thức getTaskResult.

Loại tác vụ types mà chúng tôi hỗ trợ:

  • FriendlyCaptchaTaskProxyless

Tạo tác vụ

Tạo một tác vụ nhận diện bằng phương thức createTask.

Cấu trúc đối tượng tác vụ

Thuộc tínhLoạiBắt buộcMô tả
typeChuỗiBắt buộcFriendlyCaptchaTaskProxyless
websiteURLChuỗiBắt buộcĐịa chỉ trang, nơi Friendly Captcha được giải
websiteKeyChuỗiBắt buộcKhóa trang web

Yêu cầu mẫu

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

Sau khi bạn gửi tác vụ cho chúng tôi, bạn sẽ nhận được ‘taskId’ trong phản hồi nếu thành công. Vui lòng đọc errorCode: danh sách đầy đủ các lỗi nếu bạn không nhận được id tác vụ.

Phản hồi mẫu

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

Lấy kết quả

Sau khi bạn có taskId, bạn cần gửi taskId để lấy giải pháp. Cấu trúc phản hồi được giải thích trong getTaskResult.

Yêu cầu mẫu

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

Phản hồi mẫu

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

Mã mẫu

# 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)