横向对比

标准版与企业版 reCAPTCHA v2 求解器差异

两个版本都呈现相同的“我不是机器人”复选框和图像网格挑战。区别在于后端:Enterprise 添加了原因代码、自定义规则和 Google Cloud 集成。为了解决这个问题,唯一的改变是将 enterprise=1 添加到您的 CaptchaAI 请求中 - 但检测网站使用的版本是开发人员最常出错的部分。


特性比较

特征 标准v2 企业版2
复选框小部件 是的——外观相同 是的——外观相同
形象挑战 3×3 或 4×4 网格 3×3 或 4×4 网格
JS文件 api.js enterprise.js
执行函数 grecaptcha.execute() grecaptcha.enterprise.execute()
验证接口 siteverify(免费) recaptchaenterprise.googleapis.com(付费)
原因代码 是(自动化、TOO_MUCH_TRAFFIC 等)
自定义规则 是(每个操作阈值)
谷歌云控制台 是(基于项目的管理)
密码泄露检测 是的
令牌格式 结构相同 结构相同
CaptchaAI参数 enterprise=1
典型求解时间 10-30秒 10-30秒

如何检测 Enterprise v2

主要区别在于页面加载哪个 JavaScript 文件:

检查脚本标签:

<!-- Standard v2 -->
<script src="https://www.google.com/recaptcha/api.js"></script>

<!-- Enterprise v2 -->
<script src="https://www.google.com/recaptcha/enterprise.js"></script>

自动检测(Python):

import requests
from bs4 import BeautifulSoup

def detect_recaptcha_version(url):
    resp = requests.get(url)
    soup = BeautifulSoup(resp.text, "html.parser")

    enterprise_script = soup.find("script", src=lambda s: s and "enterprise.js" in s)
    standard_script = soup.find("script", src=lambda s: s and "recaptcha/api.js" in s)

    widget = soup.find(class_="g-recaptcha")
    sitekey = widget["data-sitekey"] if widget else None

    if enterprise_script:
        return {"version": "enterprise_v2", "sitekey": sitekey}
    elif standard_script:
        return {"version": "standard_v2", "sitekey": sitekey}
    return None

info = detect_recaptcha_version("https://staging.example.com/qa-login")
print(info)

自动检测(Node.js):

const axios = require("axios");
const cheerio = require("cheerio");

async function detectRecaptchaVersion(url) {
  const { data } = await axios.get(url);
  const $ = cheerio.load(data);

  const hasEnterprise = $('script[src*="enterprise.js"]').length > 0;
  const hasStandard = $('script[src*="recaptcha/api.js"]').length > 0;
  const sitekey = $(".g-recaptcha").attr("data-sitekey");

  if (hasEnterprise) return { version: "enterprise_v2", sitekey };
  if (hasStandard) return { version: "standard_v2", sitekey };
  return null;
}

浏览器控制台检查:

// Quick check in DevTools
if (document.querySelector('script[src*="enterprise.js"]')) {
  console.log("Enterprise v2");
} else if (document.querySelector('script[src*="recaptcha/api.js"]')) {
  console.log("Standard v2");
}

使用 CaptchaAI 解决

标准v2

import requests
import time

# Submit task
resp = requests.get("https://ocr.captchaai.com/in.php", params={
    "key": "YOUR_API_KEY",
    "method": "userrecaptcha",
    "googlekey": sitekey,
    "pageurl": page_url
})
task_id = resp.text.split("|")[1]

# Poll for token
for _ in range(60):
    time.sleep(5)
    result = requests.get("https://ocr.captchaai.com/res.php", params={
        "key": "YOUR_API_KEY", "action": "get", "id": task_id
    })
    if result.text.startswith("OK|"):
        token = result.text.split("|")[1]
        break

企业版2

import requests
import time

# Submit task — only difference is enterprise=1
resp = requests.get("https://ocr.captchaai.com/in.php", params={
    "key": "YOUR_API_KEY",
    "method": "userrecaptcha",
    "googlekey": sitekey,
    "pageurl": page_url,
    "enterprise": 1  # Required for Enterprise
})
task_id = resp.text.split("|")[1]

# Polling is identical
for _ in range(60):
    time.sleep(5)
    result = requests.get("https://ocr.captchaai.com/res.php", params={
        "key": "YOUR_API_KEY", "action": "get", "id": task_id
    })
    if result.text.startswith("OK|"):
        token = result.text.split("|")[1]
        break

自动检测的通用求解器

import requests
import time
from bs4 import BeautifulSoup

class RecaptchaV2Solver:
    def __init__(self, api_key):
        self.api_key = api_key

    def detect_and_solve(self, page_url, page_html=None):
        if not page_html:
            page_html = requests.get(page_url).text

        soup = BeautifulSoup(page_html, "html.parser")
        is_enterprise = bool(soup.find("script", src=lambda s: s and "enterprise.js" in s))
        widget = soup.find(class_="g-recaptcha")
        sitekey = widget["data-sitekey"] if widget else None

        if not sitekey:
            raise Exception("No reCAPTCHA sitekey found on page")

        params = {
            "key": self.api_key,
            "method": "userrecaptcha",
            "googlekey": sitekey,
            "pageurl": page_url
        }
        if is_enterprise:
            params["enterprise"] = 1

        resp = requests.get("https://ocr.captchaai.com/in.php", params=params)
        if not resp.text.startswith("OK|"):
            raise Exception(f"Submit failed: {resp.text}")

        task_id = resp.text.split("|")[1]

        for _ in range(60):
            time.sleep(5)
            result = requests.get("https://ocr.captchaai.com/res.php", params={
                "key": self.api_key, "action": "get", "id": task_id
            })
            if result.text.startswith("OK|"):
                return {
                    "token": result.text.split("|")[1],
                    "is_enterprise": is_enterprise,
                    "sitekey": sitekey
                }
            if result.text != "CAPCHA_NOT_READY":
                raise Exception(f"Solve failed: {result.text}")

        raise Exception("Solve timed out")


solver = RecaptchaV2Solver("YOUR_API_KEY")
result = solver.detect_and_solve("https://staging.example.com/qa-login")
print(f"Enterprise: {result['is_enterprise']}, Token: {result['token'][:40]}...")

常见错误

错误 会发生什么 处理方式
在标准 v2 上使用 enterprise=1 可能会返回无效的令牌 在添加标志之前检查 enterprise.js
在 Enterprise v2 上省略 enterprise=1 令牌可能会被网站后端拒绝 enterprise.js 存在时,始终添加 enterprise=1
使用错误的站点密钥 ERROR_WRONG_GOOGLEKEY .g-recaptcha 元素上的 data-sitekey 中摘录
混淆 v2 Enterprise 与 v3 Enterprise 求解参数错误 v2 有复选框; v3 与分数不可见

token 提交——两者相同

# Selenium injection — works for both standard and enterprise
driver.execute_script(
    f'document.getElementById("g-recaptcha-response").value = "{token}";'
)

# If the page uses a callback function
callback = driver.find_element("css selector", ".g-recaptcha").get_attribute("data-callback")
if callback:
    driver.execute_script(f'{callback}("{token}");')
// Puppeteer injection — works for both
await page.evaluate((token) => {
  document.getElementById("g-recaptcha-response").value = token;
  // Find and call callback if present
  const widget = document.querySelector(".g-recaptcha");
  const cb = widget?.getAttribute("data-callback");
  if (cb && typeof window[cb] === "function") {
    window[cb](token);
  }
}, token);

常问问题

Enterprise v2 更难解决吗?

不会。挑战机制是相同的——相同的复选框、相同的图像网格。企业添加了后端分析(原因代码、自定义阈值),但不会改变求解器的挑战难度。

我可以对两个版本使用相同的代码吗?

几乎。唯一的参数差异是 enterprise=1。使用上面的自动检测方法构建一个可以处理这两种情况的代码库。检测、轮询和token 提交是相同的。

我需要处理企业原因代码吗?

不会。原因代码会在验证过程中由 Google 返回到网站后端。它们对于验证码解算器来说是不可见的。您的 CaptchaAI 集成不需要对原因代码进行任何更改。

Enterprise v2 的解决成本是否更高?

查看 CaptchaAI 的当前定价页面。企业解决方案的定价可能不同,但 API 集成工作是相同的。

我如何知道检测是否正常工作?

如果您为标准站点发送 enterprise=1,则解决可能会成功,但令牌可能会被目标站点拒绝。如果您在企业站点中忽略它,也会发生同样的情况。始终首先检查脚本 URL 进行验证。


相关指南

该文章已禁用评论。