UNLOCK API
自定义任务(Imperva、Temu 等)

自定义任务(Imperva、Temu 等)

如何通过 createTask 或 in.php 向 UNLOCK API 发送 自定义任务(Imperva、Temu 等) 任务:任务类型名称、全部参数、solution 对象、代理字段,以及 7 种语言的代码示例。
价格
$0.90 每个任务 $0.0009
你发送
class(Imperva、Temu、HUNT、tspd、Basilisk 等)及其 metadata
你得到
该 class 返回的值

简介和价格

任务类型名称

此类型只有一个名称。
CustomTask

task 对象

type
String必填
任务类型名称。不区分大小写。 CustomTask
class
String必填
要识别哪种防护,例如 Imperva 或 Temu。
websiteURL
String可选
出现验证码的页面完整地址,以 http:// 或 https:// 开头。
metadata
Object可选
所选 class 需要的额外值,以对象形式提供。
userAgent
String可选
识别时使用的浏览器 User-Agent。提交答案时请使用相同的值。

此处未列出的字段会原样传给识别方。

请求

POST /createTask
{
  "clientKey": "YOUR_API_KEY",
  "task": {
    "type": "CustomTask",
    "class": "Imperva",
    "websiteURL": "https://example.com/login",
    "metadata": {
      "incapsulaScriptUrl": "_Incapsula_Resource?SWJIYLWA=...",
      "incapsulaCookie": "incap_ses_..."
    }
  }
}

solution 对象

status 为 ready 时在 solution 中返回。
data
Object
所选 class 的答案值。
POST /getTaskResult
{
  "errorId": 0,
  "taskId": 1001,
  "status": "ready",
  "solution": {
    "data": {
      "...": "..."
    }
  },
  "cost": "0.0009",
  "createTime": 1791640000,
  "endTime": 1791640014,
  "solveCount": 1
}

代码示例

import time, requests

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

task = requests.post(f"{API}/createTask", json={
    "clientKey": KEY,
    "task": {
      "type": "CustomTask",
      "class": "Imperva",
      "websiteURL": "https://example.com/login",
      "metadata": {
        "incapsulaScriptUrl": "_Incapsula_Resource?SWJIYLWA=...",
        "incapsulaCookie": "incap_ses_..."
      }
    }
}).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")

in.php 表单方法

用传统表单请求发送同一任务。res.php 以文本形式返回答案。
in.php, res.php
curl -s "https://unlock-api.com/in.php" -d "key=YOUR_API_KEY&method=incapsula&pageurl=https://example.com/login&json=1"
# {"status":1,"request":"1001"}

curl -s "https://unlock-api.com/res.php?key=YOUR_API_KEY&action=get&id=1001&json=1"
# {"status":0,"request":"CAPCHA_NOT_READY"}  then  {"status":1,"request":"ANSWER"}

表单 API:in.php 和 res.php