Playwright 验证码解算器集成

当您的 Playwright 自动化流程需要稳定的验证码解决路径和实用的 API 集成指导时,请使用此页面。

Death By Captcha (DBC) 让 Playwright 脚本通过 API 解决验证码挑战,而无需手动交互:脚本从页面提取挑战参数、向 DBC 请求解答、将结果注入页面,然后继续流程。本页是快速入门:安装、可运行的代码示例以及受支持任务的说明。

安装

Node.js:

npm install playwright deathbycaptcha-lib

Python:

pip install deathbycaptcha-official

在客户端中使用您的 DBC 账户凭据。运行流程前,请先创建账户并查看价格与余额。

代码示例:reCAPTCHA v2 令牌流程(Node.js),改编自官方可运行示例。

const { chromium } = require('playwright');
const { HttpClient } = require('deathbycaptcha-lib');

const client = new HttpClient(process.env.DBC_USERNAME, process.env.DBC_PASSWORD);
const DEMO_URL = 'https://www.google.com/recaptcha/api2/demo';

async function solveRecaptchaV2(pageUrl, sitekey) {
  const balance = await new Promise((resolve, reject) =>
    client.get_balance((b) => (b ? resolve(b) : reject(new Error('Could not read balance')))));
  if (balance <= 0) throw new Error('No balance - top up before solving.');

  return new Promise((resolve, reject) =>
    client.decode(
      { extra: { type: 4, token_params: JSON.stringify({ googlekey: sitekey, pageurl: pageUrl }) } },
      (solution) => (solution && solution.text ? resolve(solution.text) : reject(new Error('No solution yet - retry')))
    ));
}

(async () => {
  const browser = await chromium.launch();
  const page = await browser.newPage();
  await page.goto(DEMO_URL, { timeout: 60000 });

  // 1. extract the challenge parameters
  const sitekey = await page.getAttribute('#recaptcha-demo', 'data-sitekey');

  // 2. request the solution token from DBC (type 4 = reCAPTCHA v2 token)
  const token = await solveRecaptchaV2(DEMO_URL, sitekey);

  // 3. inject the token and trigger the page callback
  await page.evaluate((t) => {
    const el = document.getElementById('g-recaptcha-response');
    if (!el) return;
    el.style.display = 'block';
    el.value = t;
    el.dispatchEvent(new Event('input', { bubbles: true }));
    el.dispatchEvent(new Event('change', { bubbles: true }));
    const cfg = window.___grecaptcha_cfg;
    if (!cfg || !cfg.clients) return;
    for (const k of Object.keys(cfg.clients)) {
      const c = cfg.clients[k];
      for (const key of Object.keys(c)) {
        const item = c[key];
        if (item && typeof item.callback === 'function') return item.callback(t);
        if (item && item.W && typeof item.W.callback === 'function') return item.W.callback(t);
      }
    }
  }, token);

  // 4. submit and wait for success
  await page.click('#recaptcha-demo-submit');
  await page.waitForSelector('.recaptcha-success', { timeout: 15000 });

  console.log('solved');
  await browser.close();
})();

完整可运行版本: 官方 Node.js 客户端仓库中的 examples/playwright

典型的 Playwright 工作流程

  1. 检测浏览器自动化流程中的挑战类型。
  2. 通过API提交挑战参数。
  3. 将返回的令牌/解决方案注入目标流。
  4. 使用显式超时策略处理重试和失败路由。

受支持任务说明

主题 说明
验证码类型(API) reCAPTCHA v2 和 v3、Cloudflare Turnstile、GeeTest、DataDome,以及图片/文字验证码。
余额 解答从账户余额中扣费;解码前请检查余额。
重试 未返回解答表示临时情况:请像官方示例那样以退避方式重试。
API 与扩展 此流程在脚本内使用 API;浏览器扩展是用于手动浏览的免代码路径。
支持的浏览器 通过 Playwright 支持 Chromium、Firefox 和 WebKit(示例已在 Chromium 上验证)。

集成注意事项

面积 为什么这很重要 推荐做法
代理一致性 降低代币流中的验证不匹配风险。 在自动化环境中保持解决和提交路径一致。
暂停纪律 防止队列停滞和不稳定的 CI 运行。 使用具有确定性回退处理的有界重试。
特定类型的处理 不同的挑战类别需要不同的有效负载字段。 从 API 类型页面开始,一次验证一种类型。

下一步实施

对于 Playwright 验证码解算器的推出,首先验证一种验证码类型,然后通过可靠性和生产规模的定价检查来扩大覆盖范围。


状态: OK

服务器以比平均响应时间更快的速度全面运行。
  • 平均求解时间
  • -- 秒 - Normal CAPTCHAs (1分钟。前)
  • 16 秒 - reCAPTCHA V2, V3 (1分钟。前)
  • 15 秒 - 其他的 (1分钟。前)
Chrome and Firefox logos
可用的浏览器扩展名

更新

  1. May 13: Crypto payments got better! You can now purchase your CAPTCHAs using cryptocurrency through the Hekelet payment processor at https://deathbycaptcha.com/user-pay and receive an extra 20% FREE CAPTCHA credit with every package purchased this way.
  2. Apr 15: GitHub Updates: We’ve upgraded our libraries, expanded sample code, enhanced documentation, and added support for C++ and Go, making integration smoother than ever. Explore what’s new at github.com/deathbycaptcha!
  3. Jan 27: RESOLVED - If your email to one of our official addresses ([email protected], [email protected], or [email protected]) has bounced or you haven’t received a response, please try resending it or reach out via our Live Chat Support at https://deathbycaptcha.com/es/contact.

  4. 之前的更新…

支持

我们的系统设计为完全用户友好且易于使用。如果您有任何问题,只需发送电子邮件至DBC 技术支持电子邮件com,支持代理将尽快与您联系。

现场支持

周一至周五可用(美国东部标准时间上午 10 点至下午 4 点) Live support image. Link to live support page