Skip to content
Programmatic guide

DataDome solver for Playwright Python

DataDome scores every request — pure headless Playwright trips the shield within seconds. Use a Sonic-issued datadome cookie to traverse protected pages without raising the score.

Python · Playwright

Runnable example

from playwright.async_api import async_playwright
from captchasonic import CaptchaSonic

sonic = CaptchaSonic('YOUR_API_KEY')
result = sonic.solve(
    type='DataDomeTask',
    website_url='https://target.example.com/protected',
    user_agent='Mozilla/5.0 (...)',
)

async with async_playwright() as p:
    browser = await p.chromium.launch()
    ctx = await browser.new_context(user_agent='Mozilla/5.0 (...)')
    await ctx.add_cookies([{ 'name': 'datadome', 'value': result.cookie, 'domain': 'target.example.com', 'path': '/' }])
    page = await ctx.new_page()
    await page.goto('https://target.example.com/protected/list')

Replace YOUR_API_KEY with a real key from your dashboard. The token is good for one form submission.

FAQ

Why pass the cookie before navigation?
DataDome scores the very first request. Pre-loading the cookie into the Playwright context means the gateway sees a valid session on byte zero instead of issuing a challenge then receiving the cookie on retry.
How long does the datadome cookie stay valid?
Typically about 1 hour per origin and fingerprint. Cache across requests within that window — re-solving on every navigation is wasted spend.
Does the cookie work in headless mode?
Yes, but pair it with a residential proxy — DataDome correlates the cookie's fingerprint with the egress IP, so a datacenter IP can still trip the shield even with a valid cookie.

How CaptchaSonic compares for this captcha

Feature-by-feature against the four most-mentioned alternatives. Independently benchmarked; numbers refresh quarterly.

FeatureCaptchaSonic2CaptchaCapSolverAnti-CaptchaCapMonster Cloud
AI / ML solver (no human relay)
AWS WAF / DataDome
Success rate (trailing 30d)99.9%~95%~98%~95%~97%
Proxy + proxyless modes
Free trial credits
SDK languages (Py, Node, Go, C#, Java, PHP)66454
Selenium / Puppeteer / Playwright examples
Browser extension
Webhook callbacks
99.9% uptime SLA

Yes / No / Partial reflect publicly documented support. Pricing and solve-time figures snapshot the published rate at the time this page was last updated.

Related guides