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



Статус: OK

Серверы полностью готовы к работе с более быстрым, чем в среднем, временем отклика.
  • Среднее время решения
  • 1 секунды - Normal CAPTCHAs (1 мин. назад)
  • 18 секунды - reCAPTCHA V2, V3 (1 мин. назад)
  • 17 секунды - другие (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:00 до 16:00 по восточному поясному времени) Live support image. Link to live support page