DeathByCaptcha API 专为需要在生产工作流程中可靠、兼容地解决验证码的团队而构建。
将此页面作为您的实施中心:客户端库、支持的验证码类型和实际的集成路径。
凭借 17 年以上的生产经验,我们的 API 已在数百万个自动化工作流程中经过实战测试。
典型流程:
.NET (C#, VB, GitHub, Selenium, Playwright, NuGet)
C (C11) (GitHub) (客户和Lib的源代码)
C++ (GitHub)
Java (GitHub, Maven, Selenium, Playwright)
Perl 5+
PHP v7+
Python3 (GitHub, PyPI, Selenium, Playwright)
Node.js (GitHub, npm, Selenium, Playwright)
Go (GitHub)
命令行工具 Windows, Linux, MacOS (请参见下面的使用说明)
对于其他语言,请查看我们的 API metadata specifications (OpenAPI/AsyncAPI) 自动生成客户端。
第三方客户
我们正在使用命令行dotnet 10+ (也支持net8.0和net6.0)
确保您已下载selenium浏览器驱动程序
并仔细检查驱动程序可执行文件是否在PATH上
您可以为Chrome使用ChromeDriver或为Firefox使用Geckodriver
并且可以在C#源代码中的这些驱动程序之间切换.
从GitHub克隆.NET项目
git clone https://github.com/deathbycaptcha/deathbycaptcha-api-client-dotnet
凭据从环境变量读取:
DBC_USERNAME=your_username
DBC_PASSWORD=your_password
在文件夹中 dbc_api_net.sln 文件位于
执行以下命令运行 Selenium 示例:
dotnet restore dbc_api_net.sln
dotnet run --project DBC_Examples/DBC_Examples.csproj -c Release -f net10.0 -p:ExamplesStartupObject=DeathByCaptcha.SeleniumRecaptchaV2Example
有关更多详细信息,请参阅.NET项目示例
我们在使用 Maven 3.6+
确保您已下载selenium浏览器驱动程序
并仔细检查 驱动程序可执行文件在PATH上
您可以为Chrome使用ChromeDriver或为Firefox使用Geckodriver
并且可以在Java源代码中的这些驱动程序之间切换.
从上面的列表中下载Java Selenium项目
编辑App.java并放入您的凭据
Client client = new HttpClient("DBC_USERNAME", "DBC_PASSWORD");
在文件夹中 pom.xml 文件位于
执行以下命令运行示例:
mvn clean install -U 清理项目和安装依赖项
mvn exec:java -Dexec.mainClass="deathbycaptcha.App" 构建项目
mvn clean 清理项目
有关更多详细信息,请参阅Java和Maven项目示例
我们在使用NodeJS v22+
确保您已下载selenium浏览器驱动程序
并仔细检查驱动程序可执行文件是否在PATH上
您可以为Chrome使用ChromeDriver或为Firefox使用Geckodriver
并且可以在NodeJS源代码中的这些驱动程序之间切换。
从GitHub克隆NodeJS项目
git clone https://github.com/deathbycaptcha/deathbycaptcha-api-client-nodejs
编辑examples/selenium/recaptcha_v2_selenium.js,并放入您的凭据
const USERNAME = 'DBC_USERNAME' // 您的DBC用户名在这里
const PASSWORD = 'DBC_PASSWORD' // 您的DBC密码在这里
在文件夹中 package.json 文件位于
执行以下命令运行示例:
npm install deathbycaptcha-lib // 从npm安装DBC库
node examples/selenium/recaptcha_v2_selenium.js // 运行示例
有关更多详细信息,请参阅NodeJS项目示例
我们在使用Python v3+
确保您已下载selenium浏览器驱动程序
并仔细检查 驱动程序可执行文件在PATH
您可以为Chrome使用ChromeDriver或为Firefox使用Geckodriver
并且可以在Python3源代码中的这些驱动程序之间切换。
从上面的列表中下载Python3 Selenium项目
编辑 python_selenium_example.py 并在那里放入您的凭据
USERNAME = 'DBC_USERNAME' # 您的DBC用户名在这里
PASSWORD = 'DBC_PASSWORD' # 您的DBC密码在这里
在文件夹中 requirements.txt 文件位于
执行以下命令运行示例:
python3 -m venv venv 创建新的python3 venv
. venv/bin/activate 激活venv
pip3 install -r requirements.txt 安装依赖项
python3 python_selenium_example.py
有关更多详细信息,请参阅Python3项目示例
Solve CAPTCHAs inside your Playwright scripts. Each example extracts the sitekey from a reCAPTCHA v2 page, sends it to the DeathByCaptcha API, and injects the token back into the page.
Supported CAPTCHA types: reCAPTCHA v2, v3, Enterprise, hCaptcha, Turnstile, GeeTest, image CAPTCHAs. Change the type parameter and payload to match your target.
Prerequisites: Active DeathByCaptcha account with balance. Credentials from API access. Auth via username/password or auth token.
Client libraries: Python · Node.js · .NET · Java
我们在使用Python v3+
Install dependencies
pip install deathbycaptcha-official playwright
playwright install
Create our Python3 script
import json
from playwright.sync_api import sync_playwright
import deathbycaptcha
username = 'your_username'
password = 'your_password'
page_url = 'https://www.google.com/recaptcha/api2/demo'
client = deathbycaptcha.SocketClient(username, password)
print('Balance:', client.get_balance())
with sync_playwright() as p:
browser = p.chromium.launch(headless=True)
page = browser.new_page()
page.goto(page_url, timeout=60000)
googlekey = page.get_attribute('#recaptcha-demo', 'data-sitekey')
result = client.decode(type=4, token_params=json.dumps({{'googlekey': googlekey, 'pageurl': page_url}}))
print('Solution:', result['text'])
page.evaluate("document.getElementById('g-recaptcha-response').value='%s'" % result['text'])
page.click('#recaptcha-demo-submit')
print(page.text_content('.recaptcha-success'))
browser.close()
Refer to Python3 project examples for more detail.
我们在使用NodeJS v22+
Install dependencies
npm install deathbycaptcha-lib playwright
npx playwright install
创建我们的Node.js脚本
const {{ chromium }} = require('playwright');
const {{ SocketClient }} = require('deathbycaptcha-lib');
const username = 'your_username';
const password = 'your_password';
const pageUrl = 'https://www.google.com/recaptcha/api2/demo';
(async () => {{
const client = new SocketClient(username, password);
const browser = await chromium.launch({{ headless: true }});
const page = await browser.newPage();
await page.goto(pageUrl, {{ timeout: 60000 }});
const googleKey = await page.getAttribute('#recaptcha-demo', 'data-sitekey');
const solution = await new Promise((resolve) => {{
client.decode({{ extra: {{ type: 4, token_params: JSON.stringify({{ googlekey: googleKey, pageurl: pageUrlresolve);
}});
console.log('Solution:', solution.text);
await page.evaluate((token) => {{
document.getElementById('g-recaptcha-response').value = token;
}}, solution.text);
await page.click('#recaptcha-demo-submit');
await page.waitForSelector('.recaptcha-success');
console.log('Success');
await browser.close();
}})();
有关更多详细信息,请参阅Node.js项目示例.
Install NuGet packages
dotnet add package DeathByCaptcha
dotnet add package Microsoft.Playwright
// Install Playwright browsers
pwsh bin/Debug/net10.0/playwright.ps1 install
// Create our C# script
using System;
using System.Collections;
using System.Text.Json;
using DeathByCaptcha;
using Microsoft.Playwright;
string username = "DBC_USERNAME";
string password = "DBC_PASSWORD";
string pageUrl = "https://www.google.com/recaptcha/api2/demo";
using var playwright = await Playwright.CreateAsync();
var browser = await playwright.Chromium.LaunchAsync();
var page = await browser.NewContextAsync().Then(ctx => ctx.NewPageAsync());
await page.GotoAsync(pageUrl, new PageGotoOptions {{ Timeout = 60000 }});
string? googleKey = await page.GetAttributeAsync("#recaptcha-demo", "data-sitekey");
var captchaData = new Hashtable {{ ["type"] = 4, ["token_params"] = JsonSerializer.Serialize(new {{ googleKey, pageUrlDeathByCaptcha.Client client = new DeathByCaptcha.HttpClient(username, password);
Captcha? solution = client.Decode(Client.DefaultTokenTimeout, captchaData);
Console.WriteLine("Solution: {0}", solution!.Text);
await page.EvaluateAsync(
"value => document.getElementById('g-recaptcha-response').value = value;",
solution.Text);
await page.ClickAsync("#recaptcha-demo-submit");
await page.WaitForSelectorAsync(".recaptcha-success");
Console.WriteLine("Success");
await browser.CloseAsync();
有关更多详细信息,请参阅.NET项目示例.
我们在使用 Maven 3.6+
Add dependencies to pom.xml
<dependency>
<groupId>io.github.deathbycaptcha</groupId>
<artifactId>deathbycaptcha-java-library</artifactId>
<version>4.7.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.52.0</version>
</dependency>
// Install Playwright browsers
mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="install"
// Create our Java script
import com.DeathByCaptcha.*;
import com.microsoft.playwright.*;
import org.json.JSONObject;
String username = "DBC_USERNAME";
String password = "DBC_PASSWORD";
String pageUrl = "https://www.google.com/recaptcha/api2/demo";
Playwright playwright = Playwright.create();
Browser browser = playwright.chromium().launch();
Page page = browser.newContext().newPage();
page.navigate(pageUrl);
String siteKey = page.getAttribute("#recaptcha-demo", "data-sitekey");
Client client = new HttpClient(username, password);
JSONObject params = new JSONObject();
params.put("googlekey", siteKey);
params.put("pageurl", pageUrl);
Captcha captcha = client.decode(params);
System.out.println("Solution: " + captcha.text);
page.evaluate(
"value => document.getElementById('g-recaptcha-response').value = value",
captcha.text);
page.click("#recaptcha-demo-submit");
page.waitForSelector(".recaptcha-success");
System.out.println("Success");
browser.close();
playwright.close();
Refer to Java project examples for more detail.
创建新的Python3虚拟环境
python3 -m venv venv
激活虚拟环境
. venv/bin/activate
从pypi安装DeathByCaptcha库
pip install deathbycaptcha-official
创建我们的python3脚本
import deathbycaptcha
# 不要忘记导入deathbycaptcha库
username = 'username'
password = 'password'
authtoken = ''
...
使用DeathByCaptcha python http客户端
http_client = deathbycaptcha.HttpClient(username, password, authtoken)
或使用DeathByCaptcha python sockets客户端
socket_client = deathbycaptcha.SocketClient(username, password, authtoken)
有关更多详细信息,请参阅Python3项目示例.
创建新的Maven项目
mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.5 -DgroupId=examples -DartifactId=deathbycaptcha-examples -Dpackage=examples -Dmaven.compiler.release=25
在maven pom.xml文件中包含以下依赖项
<dependencies>
<dependency>
<groupId>io.github.deathbycaptcha</groupId>
<artifactId>deathbycaptcha-java-library</artifactId>
<version>4.7.0</version>
</dependency>
</dependencies>
如果pom.xml正确.
我们可以在java文件中使用导入.
import com.DeathByCaptcha.AccessDeniedException;
import com.DeathByCaptcha.Client;
import com.DeathByCaptcha.HttpClient;
import com.DeathByCaptcha.SocketClient;
import com.DeathByCaptcha.Captcha;
...
清理并构建项目
mvn clean install -U
运行项目
mvn exec:java -Dexec.mainClass="examples.GetBalance" -Dexec.args=""
mvn exec:java -Dexec.mainClass="examples.ExampleRecaptchaV2"
...
有关更多详细信息,请参阅Java和Maven项目示例
使用Socket API客户端时,请确保您没有将TCP连接到端口 8123-8130 firewalled。如果套接字API客户端不适合您,请使用HTTP API客户端。 8123-8130端口范围仅适用于套接字API,请勿尝试与HTTP API使用它!
请注意,如果在验证验证验证验证之前,可以返回对解码函数/方法的调用,则可以返回null值。如果经常发生这种情况,请增加使用的超时。
有关更多详细信息,请参见每个API客户端软件包中包含的示例,并检查客户端源代码。
deathbycaptcha.exe -l USERNAME -p PASSWORD -b
deathbycaptcha.exe -a AUTHTOKEN -b
Balance.txt 文件中,并在标准输出中打印出来。
deathbycaptcha.exe -l USERNAME -p PASSWORD -c
CAPTCHA_FILE_NAME [-t TIMEOUT]
deathbycaptcha.exe -a AUTHTOKEN -c CAPTCHA_FILE_NAME [-t
TIMEOUT]
id.txt 中,验证码文本将保存在 answert.txt 中,并且ID和文本都将在标准输出由空间隔开。
deathbycaptcha.exe -l USERNAME -p PASSWORD -n
CAPTCHA_ID
deathbycaptcha.exe -a AUTHTOKEN -n CAPTCHA_ID有关 CLI 用法的更多详细信息和其他示例,请参阅 GitHub CLI 文档.
在实施自己的 Death By Captcha HTTP API客户端,请认真考虑使用上面列出的官方客户之一使用套接字API。
API URL是 http://api.dbcapi.me/api/.
url路径根据所需的动作而变化。对API提出的请求的所有答复都有两个通用字段:
status — 请求状态。 0如果内部请求处理过程中没有错误,则为255。
error — 简短说明发生的错误。仅当状态为255时返回。
有关正确的URL路径和其他返回字段的特定操作的详细信息,请参阅下面的部分。
默认情况下,所有 API 响应均返回 URL 编码。如果需要 JSON 编码,请在 接受 中包含 application/json 标头。请注意,布尔 true 将在 URL 编码响应中返回为 1,在 JSON 编码响应中返回为 true。布尔值 false 在 URL 编码响应中将返回为 0,在 JSON 编码响应中将返回为 false。
这种形式的验证码是基于图像的,需要输入扭曲图像中的一系列字母或数字。
要上传验证码,请发出一个multipart/form-data的POST请求到 http://api.dbcapi.me/api/captcha.
该请求必须包含以下字段:
username — 您的Death By Captcha用户名。password — 您的Death By Captcha密码。captchafile — 验证码图像。如果您使用令牌身份验证:
authtoken — 您的Death By Captcha身份验证令牌。captchafile — 验证码图像。captchafile 应为原始 CAPTCHA 图像文件或以 base64: 前缀预置的 base64 编码的 CAPTCHA 图像。图像文件大小限制为小于 180 KB。当图像将编码为 base64 时,大小应小于 120 KB。支持的图像格式为 JPG、PNG、GIF 和 BMP。
这是解决问题的HTML形式:
<form action="http://api.dbcapi.me/api/captcha"method="post" enctype="multipart/form-data">
<input type="text" name="username" value="">
<input type="password" name="password" value="">
<input type="file" name="captchafile">
</form>
或使用令牌身份验证:
<form action="http://api.dbcapi.me/api/captcha"method="post" enctype="multipart/form-data">
<input type="text" name="authtoken" value="">
<input type="file" name="captchafile">
</form>
这是curl命令等效:
curl --header 'Expect: ' -F username=YOUR_USERNAME -F password=YOUR_PASSWORD -F captchafile=@YOUR_CAPTCHA_FILENAME http://api.dbcapi.me/api/captcha
或使用令牌身份验证:
curl --header 'Expect: ' -F authtoken=YOUR_AUTHTOKEN -F captchafile=@YOUR_CAPTCHA_FILENAME http://api.dbcapi.me/api/captcha
base64编码captchafile字段应该看起来像这样:
base64:R0lGODlhAQABAIABAAAAAP///yH5BAEAAAEALAAAAAABAAEAAAICTAEAOw==
您将获得以下HTTP响应之一:
303 See Other 如果您的验证码成功上传,会指向已上传的验证码状态页的HTTP头Location。 您可以跟随该Location以获取已上传的验证码状态。 另外,以下字段将返回:
captcha — 上载验证码的ID。is_correct — 1如果已确定了该验证验的答案或仍在处理该答案,则0如果处理完成并且找不到答案。
text — 验证码答案。一个空字符串意味着验证码尚未解决。
status=0&captcha=123&is_correct=1&text=JSON编码示例:
{ "status": 0, "captcha": 123, "is_correct": 1, "text": "" }
403 Forbidden
如果您的Death By Captcha凭证的DeathByCaptcha被拒绝,或者您没有足够的信用。
400 Bad Request
如果您的请求未遵循上面的规范,或者因没有有效图像而被拒绝验证码。
500 Internal Server Error
如果我们一边发生了一些事情,阻止您上传验证码;如果您确定要使用有效的CATPCHA图像发送正确结构的请求,但问题仍然存在,请联系我们的实时支持,并详细告诉他们如何重现该问题。
503 Service Temporarily Unavailable
当我们的服务超载时,请稍后再试。
在这一点上,您刚刚上传的CAPTCHA可能尚未解决!如果您没有在服务器响应的text键中收到答案,则必须对其进行轮询。有关更多详细信息,请参见轮询已上传CAPTCHA状态。
要获得上传验证码的状态,请向
http://api.dbcapi.me/api/captcha/%CAPTCHA_ID%,
其中%CAPTCHA_ID%是您上传的验证码的ID,在上传验证码时获得.
这次您不必提供Death By Captcha凭据。
响应将是HTTP 200 OK响应,并包含与上传验证码部分的303 See Other响应中描述的相同字段。
如果尚未解决验证码,则text键将空。您将不得不继续进行此答案。示例响应:
status=0&captcha=1234&is_correct=1&text=tyrone+slothrop
{ "captcha": 1234, "is_correct": true,"status": 0, "text": "tyrone slothrop" }
{ "captcha": 1234, "is_correct": false, "status": 0, "text": "?" }
{ "captcha": 0, "status": 0 }
如果您得到此响应,请确认您用于轮询的验证码ID与上传时返回的答案相同。
如果问题仍然存在,请随时联系我们。
请不要在几秒钟内多次进行验证验证状态.
这被认为是滥用行为,可能会导致您被禁言。
请节约您和我们的带宽。
Solve CAPTCHAs inside your Playwright scripts. Each example extracts the sitekey from a reCAPTCHA v2 page, sends it to the DeathByCaptcha API, and injects the token back into the page.
Supported CAPTCHA types: reCAPTCHA v2, reCAPTCHA v3, reCAPTCHA Enterprise, hCaptcha, Cloudflare Turnstile, FunCaptcha, GeeTest v3/v4, and image CAPTCHAs. Change the type parameter and payload to match your target.
Prerequisites: An active DeathByCaptcha account with balance. Get your credentials from the API access page.
Authentication: Use your DBC username and password, or an auth token from the
如果您认为您的验证码已被错误地解决,请将其报告给Death By Captcha以获取您的钱。
为此,请向http://api.dbcapi.me/api/captcha/%CAPTCHA_ID%/report发出邮政请求:
username — 您的Death By Captcha用户名。password — 您的Death By Captcha密码。或使用身份验证令牌:
authtoken — 您的Death By Captcha身份验证令牌。响应将是:
200 OK 如果报告完成。在这种情况下,您的贷方将被退还。响应主体将与民意调查(或上传)相同,但is_correct字段将为0。示例:
{ "captcha": 1234, "is_correct": false,"status": 0, "text": "tyrone slothrop" }
503 Service Unavailable 如果报告无法完成。这可能是因为:滥用此功能将使您被禁止!
要查看您的信用余额,请在http://api.dbcapi.me/api上发布get或张贴请求。
username — 您的Death By Captcha用户名。password — 您的Death By Captcha密码。或使用身份验证令牌:
authtoken — 您的Death By Captcha身份验证令牌。成功验证后,您将获得200 OK响应并包含您的Death By Captcha帐户详细信息,可以是URL编码或JSON编码,包含以下字段:
user — 您的Death By Captcha帐户ID;rate — 我们向您收取多少美分的正确解决验证码费用;
balance — 您当前的信用余额,美分。is_banned — 1如果禁止用户,则0,如果不是。示例JSON编码的响应:
{ "is_banned": false, "status": 0, "rate": 0.139,"balance": 455.23, "user": 43122 }
为了接收当前服务器状态,请向http://api.dbcapi.me/api/status发出get请求。响应将具有以下字段:
todays_accuracy — 代表百分比准确性的数字(例如99.6代表99.6%)
solved_in — 平均求解时间在几秒钟内is_service_overloaded — 1如果服务超载,则0否则示例JSON编码的响应:
{ "status": 0, "todays_accuracy": 99.9, "solved_in": 5.3,"is_service_overloaded": false }
集成指南:
使用案例和定价:
比较与信任:
API specifications: