{"id":29604770,"url":"https://github.com/techinz/playwright-captcha","last_synced_at":"2026-04-19T03:06:47.962Z","repository":{"id":304371710,"uuid":"1018627923","full_name":"techinz/playwright-captcha","owner":"techinz","description":"Automating captcha solving for Playwright. Supports Cloudflare Turnstile \u0026 Interstitial, and reCAPTCHA V2 \u0026 V3 with Click-based or API (2captcha) solving. Designed for easy integration with Playwright, Patchright, and Camoufox.","archived":false,"fork":false,"pushed_at":"2025-07-12T17:33:23.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-12T18:30:06.402Z","etag":null,"topics":["automation","bot","camoufox","captcha","detection","patchright","playwright"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/playwright-captcha","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techinz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-12T17:13:02.000Z","updated_at":"2025-07-12T18:00:34.000Z","dependencies_parsed_at":"2025-07-12T18:30:09.229Z","dependency_job_id":"dceca3d5-1119-4a27-bcec-f8d26dedab05","html_url":"https://github.com/techinz/playwright-captcha","commit_stats":null,"previous_names":["techinz/playwright-captcha"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/techinz/playwright-captcha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techinz%2Fplaywright-captcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techinz%2Fplaywright-captcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techinz%2Fplaywright-captcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techinz%2Fplaywright-captcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techinz","download_url":"https://codeload.github.com/techinz/playwright-captcha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techinz%2Fplaywright-captcha/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266152247,"owners_count":23884472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["automation","bot","camoufox","captcha","detection","patchright","playwright"],"created_at":"2025-07-20T16:00:30.163Z","updated_at":"2026-04-19T03:06:47.948Z","avatar_url":"https://github.com/techinz.png","language":"Python","funding_links":[],"categories":["Scraping \u0026 Automation"],"sub_categories":[],"readme":"# Playwright Captcha\n\n[![Python 3.8+](https://img.shields.io/badge/Python-3.8+-blue.svg)](https://www.python.org/downloads/)\n[![PyPI version](https://img.shields.io/pypi/v/playwright-captcha.svg)](https://pypi.org/project/playwright-captcha/)\n\nA 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!\n\n\u003ci\u003e(Need some help with \u003cb\u003eAutomation\u003c/b\u003e? You can  \u003ca href=\"https://automation.techinz.dev\"\u003ehire me\u003c/a\u003e for custom development or consulting!)\u003c/i\u003e\n\n## ✨ What it does\n\nThis framework helps you solve captchas in Playwright or Playwright-based frameworks (like Camoufox or Patchright) automatically. It will:\n\n1. **Detect** the captcha on your page\n2. **Solve** it using your preferred method \n3. **Apply** the solution automatically\n4. **Submit** the form (when needed \u0026 possible)\n\n\n## 📸 Demonstration (recorded in headless mode)\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch2\u003eClick Solver\u003c/h2\u003e\n  \u003ch4\u003eCloudflare Interstitial\u003c/h4\u003e\n\n  https://github.com/user-attachments/assets/06c244ff-ba82-4d8a-9ef8-17ece400716c\n    \n  \u003cdetails\u003e \n  \u003csummary\u003e\u003ch4\u003eCloudflare Turnstile\u003c/h4\u003e\u003c/summary\u003e\n\n  https://github.com/user-attachments/assets/52b49abd-5aa4-4262-9cb6-a555a95330c9\n\n  \u003c/details\u003e\n\n  \u003ch2\u003eAPI Solver (Twocaptcha used here but others work similarly)\u003c/h2\u003e\n\n  \u003cdetails\u003e \n  \u003csummary\u003e\u003ch4\u003eCloudflare Interstitial\u003c/h4\u003e\u003c/summary\u003e\n    \n  https://github.com/user-attachments/assets/25a6233b-43fb-4164-b41c-ea80100b501d\n\n  \u003c/details\u003e\n\n  \u003cdetails\u003e \n  \u003csummary\u003e\u003ch4\u003eCloudflare Turnstile\u003c/h4\u003e\u003c/summary\u003e\n    \n  https://github.com/user-attachments/assets/0f3f7999-1e0d-437e-9727-36a99a6c5abd\n\n  \u003c/details\u003e\n\n  \u003cdetails\u003e \n  \u003csummary\u003e\u003ch4\u003eReCaptcha V2\u003c/h4\u003e\u003c/summary\u003e\n  \n  https://github.com/user-attachments/assets/37b5d9b0-7c32-49b3-9c22-ffe0258161d1\n\n  \u003c/details\u003e\n\n  \u003cdetails\u003e \n  \u003csummary\u003e\u003ch4\u003eReCaptcha V3\u003c/h4\u003e\u003c/summary\u003e\n  \n  https://github.com/user-attachments/assets/7fc7d508-be87-4c60-aaf8-ab445601e69c\n\n  \u003c/details\u003e\n\u003c/div\u003e\n\n## ⚠️ LEGAL DISCLAIMER\n\n**THIS TOOL IS PROVIDED FOR EDUCATIONAL AND RESEARCH PURPOSES ONLY**\n\nThis 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:\n\n- The Computer Fraud and Abuse Act (CFAA)\n- Terms of Service agreements\n- Various cybersecurity laws in your jurisdiction\n\n## 🚀 Supported Captcha Types\n\n### Click Solver\nUses the browser's stealthiness to automatically click and solve captchas (works good only with playwright's stealthy patches e.g. camoufox/patchright):\n- ✅ Cloudflare Interstitial\n- ✅ Cloudflare Turnstile\n\n### API Solver\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ch4\u003eTwoCaptcha - https://2captcha.com\u003c/h4\u003e\u003c/summary\u003e\n\n Uses the 2Captcha.com API for solving:\n- ✅ Cloudflare Interstitial\n- ✅ Cloudflare Turnstile\n- ✅ reCAPTCHA v2\n- ✅ reCAPTCHA v3\n\n  \u003c/details\u003e\n\n\u003cdetails\u003e\n  \u003csummary\u003e\u003ch4\u003eTenCaptcha - https://10captcha.com\u003c/h4\u003e\u003c/summary\u003e\n\n Uses the 10Captcha.com API for solving:\n- ✅ reCAPTCHA v2\n- ✅ reCAPTCHA v3\n\n  \u003c/details\u003e\n\n*More captcha types and solvers coming soon! Contributions welcome.*\n\n## 📦 Installation\n\n```bash\npip install playwright-captcha\n```\n\n## 🔧 Quick Start\n\nCheck out the [examples](examples/) directory for detailed usage examples:\n\n- **[Cloudflare Examples](examples/cloudflare/)**: Turnstile and Interstitial challenges\n- **[reCAPTCHA Examples](examples/recaptcha/)**: v2 and v3 implementations\n\nEach example includes configurations for Playwright, Patchright, and Camoufox.\n\n### Click Solver Example\n\n```python\nimport asyncio\nfrom playwright.async_api import async_playwright\nfrom playwright_captcha import CaptchaType, ClickSolver, FrameworkType\n\nasync def solve_captcha():\n    async with async_playwright() as playwright:\n        browser = await playwright.chromium.launch(headless=True)\n        page = await browser.new_page()\n        \n        framework = FrameworkType.PLAYWRIGHT\n        \n        # Create solver before navigating to the page\n        async with ClickSolver(framework=framework, page=page) as solver:\n            # Navigate to your target page\n            await page.goto('https://example.com/with-captcha')\n            \n            # Solve the captcha\n            await solver.solve_captcha(\n                captcha_container=page,\n                captcha_type=CaptchaType.CLOUDFLARE_TURNSTILE\n            )\n        \n        # Continue with your automation...\n\nasyncio.run(solve_captcha())\n```\n\n### API Solver Example (TwoCaptcha)\n\n```python\nimport asyncio\nimport os\nfrom playwright.async_api import async_playwright\nfrom twocaptcha import AsyncTwoCaptcha\nfrom playwright_captcha import CaptchaType, TwoCaptchaSolver, FrameworkType\n\nasync def solve_with_2captcha():\n    # Initialize 2Captcha client\n    captcha_client = AsyncTwoCaptcha(os.getenv('TWO_CAPTCHA_API_KEY'))\n    \n    async with async_playwright() as playwright:\n        browser = await playwright.chromium.launch(headless=False)\n        page = await browser.new_page()\n                \n        framework = FrameworkType.PLAYWRIGHT\n        \n        # Create solver before navigating to the page\n        # Available API Solvers:\n        # TwoCaptchaSolver\n        # TenCaptchaSolver\n        \n        async with TwoCaptchaSolver(framework=framework, \n                                    page=page, \n                                    async_two_captcha_client=captcha_client) as solver:\n            # Navigate to your target page\n            await page.goto('https://example.com/with-recaptcha')\n        \n            # Solve reCAPTCHA v2\n            await solver.solve_captcha(\n                captcha_container=page,\n                captcha_type=CaptchaType.RECAPTCHA_V2\n            )\n        \n        # Continue with your automation...\n\nasyncio.run(solve_with_2captcha())\n```\n\n## 🎯 How It Works\n\n### Click Solver Process:\n1. **Find** the captcha element on the page\n2. **Click** on it using browser automation\n3. **Wait** for successful completion\n\n### External Solver Process (e.g., TwoCaptcha, TenCaptcha):\n1. **Find** the captcha element\n2. **Extract** required data (site key, URL, etc.)\n3. **Send** to external solving service\n4. **Apply** the returned solution\n5. **Submit** the form (when applicable)\n\n## 🗺️ TODO\n\n### 🎯 Next Captcha Types\n- [ ] **hCaptcha**\n\n### 🔧 New Solver Types\n- [ ] **CapSolver**\n- [ ] **AI Solver**\n\n### Other\n- [ ] **Unit \u0026 Integration Tests**\n\n## 🌐 Browser Compatibility\n\n### Standard Playwright\nWorks with all standard Playwright browsers (Chrome, Firefox, Safari).\n\n### Stealth Browsers\nFor better success rates, especially with click-based solving:\n\n#### Patchright\n```python\nfrom patchright.async_api import async_playwright\nfrom playwright_captcha import FrameworkType\n\nasync with async_playwright() as playwright:\n    browser = await playwright.chromium.launch(channel=\"chrome\", headless=False)\n    \n    framework = FrameworkType.PATCHRIGHT\n    \n    # ... rest of your code\n```\n\n#### Camoufox\n```python\nfrom camoufox import AsyncCamoufox\nfrom playwright_captcha.utils.camoufox_add_init_script.add_init_script import get_addon_path\nfrom playwright_captcha import FrameworkType\nimport os\n\nADDON_PATH = get_addon_path()\n\nasync with AsyncCamoufox(\n    headless=False,\n    geoip=True,\n    humanize=True,\n    main_world_eval=True, # add this\n    addons=[os.path.abspath(ADDON_PATH)] # add this\n) as browser:\n    context = await browser.new_context()\n    page = await context.new_page()\n    \n    framework = FrameworkType.CAMOUFOX\n    \n    # ... rest of your code\n```\n\n\u003e **Note**: Camoufox currently has an issue with the `add_init_script` method. I've included a temporary workaround that's automatically used in the package. See the [examples](examples/) folder for details.\n\n## 📁 Project Structure\n\n```\nplaywright-captcha/\n├── examples/                   # Usage examples\n│   ├── cloudflare/             # Cloudflare captcha examples\n│   └── recaptcha/              # reCAPTCHA examples\n└── playwright_captcha/         # Main package\n    ├── captchas/               # Captcha type implementations\n    ├── solvers/                # Solver implementations\n    ├── types/                  # Type definitions\n    └── utils/                  # Utility functions\n```\n\n## 🔧 Configuration\n\n### Environment Variables\n\n(Optional) Create a `.env` file for your API keys:\n\n```env\nTWO_CAPTCHA_API_KEY=your_2captcha_api_key_here\nTEN_CAPTCHA_API_KEY=your_10captcha_api_key_here\n```\n\n### Solver Options\n\n```python\n# Click solver with custom settings\nsolver = ClickSolver(\n    framework=framework, # Framework type (PLAYWRIGHT, PATCHRIGHT, CAMOUFOX)\n    page=page,\n    max_attempts=5,      # Number of solving attempts\n    attempt_delay=3      # Delay between attempts (seconds)\n)\n\n# API solver with custom settings (TwoCaptcha)\nsolver = TwoCaptchaSolver(\n    framework=framework, # Framework type (PLAYWRIGHT, PATCHRIGHT, CAMOUFOX)\n    page=page,\n    async_two_captcha_client=captcha_client,\n    max_attempts=3,\n    attempt_delay=10,\n    \n    # also you can specify the captcha data like sitekey manually if it fails to detect automatically\n    sitekey='sitekey'\n    # ...\n)\n```\n\n## 🆘 Support\n\n- 📖 Check the [examples](examples/) folder for usage patterns\n- 🐛 Report issues or request features on [GitHub Issues](https://github.com/techinz/playwright-captcha/issues)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechinz%2Fplaywright-captcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechinz%2Fplaywright-captcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechinz%2Fplaywright-captcha/lists"}