UNLOCK API
reCAPTCHA v2 Enterprise

reCAPTCHA v2 Enterprise

如何通过 createTask 或 in.php 向 UNLOCK API 发送 reCAPTCHA v2 Enterprise 任务:任务类型名称、全部参数、solution 对象、代理字段,以及 7 种语言的代码示例。
价格
$0.50 每个任务 $0.0005
你发送
页面网址、site key,以及网站使用的 enterprise payload(如有)
你得到
用于 g-recaptcha-response 的令牌

简介和价格

任务类型名称

不使用代理时用第一个名称。要通过你自己的代理识别,用第二个名称并加上代理字段。价格相同。
RecaptchaV2EnterpriseTaskProxyless不使用代理
RecaptchaV2EnterpriseTask使用你的代理

task 对象

type
String必填
任务类型名称。不区分大小写。 RecaptchaV2EnterpriseTaskProxyless | RecaptchaV2EnterpriseTask
websiteURL
String必填
出现验证码的页面完整地址,以 http:// 或 https:// 开头。
websiteKey
String必填
验证码组件的站点密钥,可在页面源代码中找到(例如 data-sitekey)。
enterprisePayload
Object可选
页面传给 grecaptcha.enterprise.render 的额外值,例如 s。
isInvisible
Boolean可选
隐藏版(invisible)组件时为 true。
userAgent
String可选
识别时使用的浏览器 User-Agent。提交答案时请使用相同的值。
cookies
String可选
页面的 Cookie,name=value 对,用分号分隔。
apiDomain
String可选
组件加载所用的域名:google.com 或 recaptcha.net。

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

代理字段

仅用于代理类型名称。可以分别发送各字段,也可以发送一个 proxy 字符串。
proxyType
String必填
http、https、socks4 或 socks5。
proxyAddress
String必填
代理 IP 地址或主机名。
proxyPort
Integer必填
代理端口。
proxyLogin
String可选
代理用户名(如果代理需要)。
proxyPassword
String可选
代理密码(如果代理需要)。
proxy
String
把所有代理字段写成一个字符串,例如 http://user:pass@1.2.3.4:8080。

使用代理

请求

POST /createTask
{
  "clientKey": "YOUR_API_KEY",
  "task": {
    "type": "RecaptchaV2EnterpriseTaskProxyless",
    "websiteURL": "https://example.com/login",
    "websiteKey": "6LcR_RsTAAAAAFJR_5ZdbQd0SMxL7yIDmSXH1-lo"
  }
}

solution 对象

status 为 ready 时在 solution 中返回。
gRecaptchaResponse
String
令牌。填入 g-recaptcha-response 字段(hCaptcha 为 h-captcha-response),或传给页面回调。
POST /getTaskResult
{
  "errorId": 0,
  "taskId": 1001,
  "status": "ready",
  "solution": {
    "gRecaptchaResponse": "03AGdBq25SxXT-pmSeBXjzScW..."
  },
  "cost": "0.0005",
  "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": "RecaptchaV2EnterpriseTaskProxyless",
      "websiteURL": "https://example.com/login",
      "websiteKey": "6LcR_RsTAAAAAFJR_5ZdbQd0SMxL7yIDmSXH1-lo"
    }
}).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"]["gRecaptchaResponse"])
        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=userrecaptcha&enterprise=1&googlekey=SITE_KEY&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