How to Use DeathByCaptcha with Puppeteer for Browser Automation
Puppeteer is the leading browser automation library for Node.js, commonly used for web scraping, testing, and monitoring. When automated Puppeteer scripts hit CAPTCHA walls, integrating a puppeteer captcha solver keeps your workflows running.
This guide shows how to connect Puppeteer with DeathByCaptcha using Node.js.
The workflow looks like this:

Prerequisites
- Node.js 16+
- A DeathByCaptcha account (free trial)
- Puppeteer installed (
npm install puppeteer)
Step 1: Install the DBC Node.js Client
npm install deathbycaptcha
Step 2: Connect to DBC
const DBC = require('deathbycaptcha');
const client = new DBC.SocketClient('username', 'password');
Step 3: Detect and Solve CAPTCHAs
const puppeteer = require('puppeteer');
async function solveCaptcha(page) {
const screenshot = await page.screenshot({ encoding: 'base64' });
const result = await client.decode(
Buffer.from(screenshot, 'base64'), 60
);
if (result.text) {
await page.type('#captcha-input', result.text);
await page.click('#submit-button');
}
}
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://example.com');
const captchaPresent = await page.$('#captcha-image');
if (captchaPresent) await solveCaptcha(page);
await browser.close();
})();
Step 4: Handling reCAPTCHA with Puppeteer
For reCAPTCHA v2, capture the site key and page URL, then use DBC's endpoint:
const result = await client.decode({
googlekey: 'SITE_KEY',
pageurl: 'https://example.com'
}, 60, 4);
Inject the token back into the page:
await page.evaluate((token) => {
document.getElementById('g-recaptcha-response').innerHTML = token;
}, result.text);
Step 5: Solving reCAPTCHA from Other Languages
The reCAPTCHA call above works from any language. Here are the equivalents:
Python
import deathbycaptcha
client = deathbycaptcha.SocketClient("username", "password")
result = client.decode({
"googlekey": "SITE_KEY",
"pageurl": "https://example.com"
}, type=4, timeout=60)
if result:
token = result.text
print(f"Token: {token}")
PHP
require_once 'deathbycaptcha.php';
$client = new DeathByCaptcha_HttpClient("username", "password");
$token_params = json_encode([
'googlekey' => 'SITE_KEY',
'pageurl' => 'https://example.com',
]);
$captcha = $client->decode(null, ['type' => 4, 'token_params' => $token_params]);
if ($captcha) {
echo "reCAPTCHA token: " . $captcha["text"] . "\n";
}
Java
import com.DeathByCaptcha.Client;
import com.DeathByCaptcha.HttpClient;
import com.DeathByCaptcha.Captcha;
import org.json.JSONObject;
Client client = new HttpClient("username", "password");
JSONObject params = new JSONObject();
params.put("googlekey", "SITE_KEY");
params.put("pageurl", "https://example.com");
Captcha captcha = client.decode(4, params);
if (captcha != null) {
System.out.println("reCAPTCHA token: " + captcha.text);
}
Go
package main
import (
"encoding/json"
"fmt"
"log"
dbc "github.com/deathbycaptcha/deathbycaptcha-api-client-go/v4/deathbycaptcha"
)
func main() {
client := dbc.NewHttpClient("username", "password")
defer client.Close()
tokenParams, _ := json.Marshal(map[string]string{
"googlekey": "SITE_KEY",
"pageurl": "https://example.com",
})
captcha, err := client.Decode(nil, dbc.DefaultTokenTimeout, map[string]string{
"type": "4",
"token_params": string(tokenParams),
})
if err != nil {
log.Fatal(err)
}
if captcha != nil {
fmt.Println("reCAPTCHA token:", *captcha.Text)
}
}
C
using System.Collections;
using DeathByCaptcha;
Client client = new DeathByCaptcha.HttpClient("username", "password");
string tokenParams = "{\"googlekey\":\"SITE_KEY\",\"pageurl\":\"https://example.com\"}";
Captcha captcha = client.Decode(Client.DefaultTimeout,
new Hashtable { { "type", 4 }, { "token_params", tokenParams } });
if (captcha != null)
Console.WriteLine("reCAPTCHA token: " + captcha.Text);
cURL
curl --data-urlencode "username=YOUR_USERNAME" \
--data-urlencode "password=YOUR_PASSWORD" \
--data-urlencode "type=4" \
--data-urlencode 'token_params={"googlekey":"SITE_KEY","pageurl":"https://example.com"}' \
http://api.dbcapi.me/api/captcha
The response is JSON and the reCAPTCHA token arrives in the text field.
Best Practices
- Use DBC's callback mode for high-volume workflows.
- Implement exponential backoff for captcha retries.
- Rotate user agents and viewport sizes to reduce detection.
- Monitor your DBC balance programmatically.

English
Spanish
Russian
Chinese
French
Hindi
Arabic
Bengali
Indonesian
Portuguese
com, 