How to Use DeathByCaptcha with Selenium: Step-by-Step Guide

How to Use DeathByCaptcha with Selenium: Step-by-Step Guide

Posted on 2026-07-17 | Category: guides


How to Use DeathByCaptcha with Selenium: Step-by-Step Guide

Selenium is the most widely used browser automation framework, and CAPTCHA challenges are one of the most common reasons Selenium scripts break in production. Integrating DeathByCaptcha's selenium captcha solver into your Selenium workflow takes only a few lines of code.

This guide walks through a complete integration using Python and the DBC API.

Prerequisites

  • Python 3.7+
  • A DeathByCaptcha account (free trial available)
  • Selenium installed (pip install selenium)
  • A WebDriver for your browser (ChromeDriver, GeckoDriver, etc.)

Step 1: Install the DBC Client

DBC provides an official Python client library:

pip install deathbycaptcha

Step 2: Set Up the DBC Client

import deathbycaptcha

username = "your_username"
password = "your_password"
client = deathbycaptcha.SocketClient(username, password)
client.is_verbose = True

Step 3: Capture and Solve a CAPTCHA

When your Selenium script encounters a CAPTCHA, capture the element and send it to DBC:

from selenium import webdriver
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://example.com")

# When a CAPTCHA appears, capture the image
captcha_element = driver.find_element(By.CSS_SELECTOR, "#captcha-image")
captcha_element.screenshot("captcha.png")

# Send to DBC for solving
with open("captcha.png", "rb") as f:
    captcha_data = f.read()

captcha_id, solution = client.decode(captcha_data, timeout=60)
if solution:
    input_field = driver.find_element(By.CSS_SELECTOR, "#captcha-input")
    input_field.send_keys(solution)
    submit_button = driver.find_element(By.CSS_SELECTOR, "#submit")
    submit_button.click()

Step 4: Handling reCAPTCHA

For reCAPTCHA, use DBC's dedicated endpoint:

captcha_id, solution = client.decode(
    {"googlekey": "SITE_KEY", "pageurl": "https://example.com"},
    type=4
)

Best Practices

  • Reuse the DBC client connection instead of creating a new one for each captcha.
  • Set appropriate timeouts (15s for automated solves, 60s for human-assisted).
  • Handle errors gracefully with try/except blocks.
  • Use DBC's callback mode for high-throughput workflows.

Next Steps



Estado: OK

Los servidores están completamente operativos con un tiempo de respuesta más rápido que el promedio.
  • Tiempo medio de resolución
  • 1 segundos - Normal CAPTCHAs (1 min. atrás)
  • 18 segundos - reCAPTCHA V2, V3 (1 min. atrás)
  • 17 segundos - otros (1 min. atrás)
Chrome and Firefox logos
Extensiones de navegador disponibles

Actualizaciones

  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. Actualizaciones anteriores…

Apoyo

Nuestro sistema está diseñado para ser completamente fácil de usar. Si tiene algún problema con él, simplemente envíenos un correo electrónico a Correo electrónico de soporte técnico de DBC com, y un agente de soporte se comunicará con usted lo antes posible.

Soporte en vivo

Disponible de lunes a viernes (10 am a 4 pm EST) Live support image. Link to live support page