Puppeteer + DeathByCaptcha: Step-by-Step Browser Automation

Puppeteer + DeathByCaptcha: Step-by-Step Browser Automation

Posted on 2026-07-17 | Last Updated: 2026-08-17 | 3 min read | Category: browser-automation-guide | By DeathByCaptcha Engineering Team

Browser Automation Guide


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:

Puppeteer CAPTCHA solving workflow with DeathByCaptcha

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.

Next Steps

Common pitfalls

  • Using a CAPTCHA solving service for illegitimate purposes instead of legitimate automation and testing.
  • Hard-coding credentials or API keys in client-side code that users can inspect.
  • Sending the wrong CAPTCHA type parameter, which returns incorrect or empty responses.
  • Failing to poll for the solution status and not handling timeouts gracefully.
  • Scaling automation without monitoring error rates, response times, and CAPTCHA type coverage.
DBC
Written by DeathByCaptcha Engineering Team
DeathByCaptcha engineers build and operate the CAPTCHA solving technology behind this site. Articles are written by our technical team and checked for accuracy before publishing.
Reviewed by DeathByCaptcha Editorial Team

Start solving CAPTCHAs today

Create a free account and get started with the DeathByCaptcha API in minutes. No credit card required.

Create a free account


Status: OK

Os servidores estão totalmente operacionais com tempo de resposta mais rápido que a média.
  • Tempo médio de resolução
  • -- segundos - Normal CAPTCHAs (1 min. atrás)
  • 16 segundos - reCAPTCHA V2, V3 (1 min. atrás)
  • 7 segundos - outros (1 min. atrás)
Chrome and Firefox logos
Extensões do navegador disponíveis

Atualizações

  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 (help@deathbycaptcha.com, payments@deathbycaptcha.com, or captcha.admin@deathbycaptcha.com) 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. Atualizações anteriores…

Apoiar

Nosso sistema foi projetado para ser totalmente amigável e fácil de usar. Se você tiver algum problema com isso, basta enviar um e-mail paraE-mail de suporte técnico DBC com, e um agente de suporte entrará em contato com você o mais rápido possível.

Suporte ao vivo

Disponível de segunda a sexta-feira (10h às 16h EST) Live support image. Link to live support page