UNLOCK API

複合画像タスク解決API

複合画像タスクのタスクをAPIに送ると、コードがページに送信する回答が返ってきます。class(recaptcha、hcaptcha、funcaptcha、recognition)、画像、タスクのテキスト。受け取るもの: 一致する画像またはセル。

概要

1,000件あたりの料金
$0.60 (1タスク $0.0006)
createTaskのtype
ComplexImageTask
in.phpのmethod
送信するもの
class(recaptcha、hcaptcha、funcaptcha、recognition)、画像、タスクのテキスト
受け取るもの
一致する画像またはセル

値の見つけ方

画像をリストで送り、指示をmetadataに入れます。

createTaskとgetTaskResult

タスクを作成し、約5秒待ってから、statusがreadyになるまで5秒ごとに結果を確認します。タスクが失敗した場合はAPIがエラーを返し、料金は残高に戻ります。

import time, requests

API = "https://unlock-api.com"
KEY = "YOUR_API_KEY"

task = requests.post(f"{API}/createTask", json={
    "clientKey": KEY,
    "task": {
      "type": "ComplexImageTask",
      "class": "recaptcha",
      "imagesBase64": [
        "/9j/4AAQSkZJRgABAQ..."
      ],
      "metadata": {
        "Task": "Select all images with a bus",
        "Grid": "3x3"
      }
    }
}).json()
if task["errorId"]:
    raise SystemExit(task["errorCode"])

for _ in range(60):   # 60 x 5 s = the 5 minute task limit
    time.sleep(5)
    r = requests.post(f"{API}/getTaskResult", json={"clientKey": KEY, "taskId": task["taskId"]}).json()
    if r["errorId"]:
        raise SystemExit(f"{r['errorCode']}: {r.get('errorDescription', '')}")   # failed tasks are refunded
    if r["status"] == "ready":
        print(r["solution"])
        break
else:
    raise SystemExit("timed out")

APIリファレンス全文: すべてのパラメータとsolutionオブジェクト