
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
playwright-captcha
Advanced tools
Automating captcha solving for Playwright. Supports Cloudflare Turnstile & Interstitial, and reCAPTCHA V2 & V3 with Click-based or API (2captcha) solving. Designed for easy integration with Playwright, Patchright, and Camoufox.
A Python library that makes captcha solving simple and automated with Playwright and Playwright-based frameworks. Just a few lines of code, and you're ready to go!
This framework helps you solve captchas in Playwright or Playwright-based frameworks (like Camoufox or Patchright) automatically. It will:
https://github.com/user-attachments/assets/06c244ff-ba82-4d8a-9ef8-17ece400716c
https://github.com/user-attachments/assets/52b49abd-5aa4-4262-9cb6-a555a95330c9
https://github.com/user-attachments/assets/25a6233b-43fb-4164-b41c-ea80100b501d
https://github.com/user-attachments/assets/0f3f7999-1e0d-437e-9727-36a99a6c5abd
THIS TOOL IS PROVIDED FOR EDUCATIONAL AND RESEARCH PURPOSES ONLY
This software is designed to demonstrate security concepts and should not be used to bypass protections on websites without explicit permission from the website owner. Using this tool against websites without authorization may violate:
Uses the browser's stealthiness to automatically click and solve captchas (works good only with playwright's stealthy patches e.g. camoufox/patchright):
Uses the 2Captcha.com API for solving:
More captcha types and solvers coming soon! Contributions welcome.
pip install playwright-captcha
Check out the examples directory for detailed usage examples:
Each example includes configurations for Playwright, Patchright, and Camoufox.
import asyncio
from playwright.async_api import async_playwright
from playwright_captcha import CaptchaType, ClickSolver, FrameworkType
async def solve_captcha():
async with async_playwright() as playwright:
browser = await playwright.chromium.launch(headless=True)
page = await browser.new_page()
framework = FrameworkType.PLAYWRIGHT
# Create solver before navigating to the page
async with ClickSolver(framework=framework, page=page) as solver:
# Navigate to your target page
await page.goto('https://example.com/with-captcha')
# Solve the captcha
await solver.solve_captcha(
captcha_container=page,
captcha_type=CaptchaType.CLOUDFLARE_TURNSTILE
)
# Continue with your automation...
asyncio.run(solve_captcha())
import asyncio
import os
from playwright.async_api import async_playwright
from twocaptcha import AsyncTwoCaptcha
from playwright_captcha import CaptchaType, TwoCaptchaSolver, FrameworkType
async def solve_with_2captcha():
# Initialize 2Captcha client
captcha_client = AsyncTwoCaptcha(os.getenv('TWO_CAPTCHA_API_KEY'))
async with async_playwright() as playwright:
browser = await playwright.chromium.launch(headless=False)
page = await browser.new_page()
framework = FrameworkType.PLAYWRIGHT
# Create solver before navigating to the page
async with TwoCaptchaSolver(framework=framework,
page=page,
async_two_captcha_client=captcha_client) as solver:
# Navigate to your target page
await page.goto('https://example.com/with-recaptcha')
# Solve reCAPTCHA v2
await solver.solve_captcha(
captcha_container=page,
captcha_type=CaptchaType.RECAPTCHA_V2
)
# Continue with your automation...
asyncio.run(solve_with_2captcha())
Works with all standard Playwright browsers (Chrome, Firefox, Safari).
For better success rates, especially with click-based solving:
from patchright.async_api import async_playwright
from playwright_captcha import FrameworkType
async with async_playwright() as playwright:
browser = await playwright.chromium.launch(channel="chrome", headless=False)
framework = FrameworkType.PATCHRIGHT
# ... rest of your code
from camoufox import AsyncCamoufox
from playwright_captcha.utils.camoufox_add_init_script.add_init_script import get_addon_path
from playwright_captcha import FrameworkType
import os
ADDON_PATH = get_addon_path()
async with AsyncCamoufox(
headless=False,
geoip=True,
humanize=True,
main_world_eval=True, # add this
addons=[os.path.abspath(ADDON_PATH)] # add this
) as browser:
context = await browser.new_context()
page = await context.new_page()
framework = FrameworkType.CAMOUFOX
# ... rest of your code
Note: Camoufox currently has an issue with the
add_init_scriptmethod. I've included a temporary workaround that's automatically used in the package. See the examples folder for details.
playwright-captcha/
├── examples/ # Usage examples
│ ├── cloudflare/ # Cloudflare captcha examples
│ └── recaptcha/ # reCAPTCHA examples
└── playwright_captcha/ # Main package
├── captchas/ # Captcha type implementations
├── solvers/ # Solver implementations
├── types/ # Type definitions
└── utils/ # Utility functions
(Optional) Create a .env file for your API keys:
TWO_CAPTCHA_API_KEY=your_2captcha_api_key_here
# Click solver with custom settings
solver = ClickSolver(
framework=framework, # Framework type (PLAYWRIGHT, PATCHRIGHT, CAMOUFOX)
page=page,
max_attempts=5, # Number of solving attempts
attempt_delay=3 # Delay between attempts (seconds)
)
# TwoCaptcha solver with custom settings
solver = TwoCaptchaSolver(
framework=framework, # Framework type (PLAYWRIGHT, PATCHRIGHT, CAMOUFOX)
page=page,
async_two_captcha_client=captcha_client,
max_attempts=3,
attempt_delay=10,
# also you can specify the captcha data like sitekey manually if it fails to detect automatically
sitekey='sitekey'
# ...
)
FAQs
Automating captcha solving for Playwright. Supports Cloudflare Turnstile & Interstitial, and reCAPTCHA V2 & V3 with Click-based or API (2captcha) solving. Designed for easy integration with Playwright, Patchright, and Camoufox.
We found that playwright-captcha demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.