Skip to main content

2Captcha Extension Python

2Captcha Extension Python helps you easily use 2Captcha Extension in Botasaurus, Selenium, and Playwright.

You can easily configure 2Captcha with an API key without needing to download the 2Captcha Extension, update config files, etc.

Installation

python -m pip install twocaptcha_extension_python

Usage with Botasaurus Web Scraping Framework

from botasaurus import *
from twocaptcha_extension_python import TwoCaptcha

@browser(
    extensions=[TwoCaptcha(api_key="TWO_CAPTCHA_KEY")], # TODO: Replace with your own 2Captcha Key
)  
def solve_captcha(driver: AntiDetectDriver, data):
    driver.get("https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php")
    driver.prompt()

solve_captcha()

Usage with Selenium

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from chromedriver_autoinstaller import install
from twocaptcha_extension_python import TwoCaptcha

# Set Chrome options
options = Options()
options.add_argument(TwoCaptcha(api_key="TWO_CAPTCHA_KEY").load()) # TODO: Replace with your own 2Captcha Key
# Install and set up the driver
driver_path = install()
driver = webdriver.Chrome(driver_path, options=options)

# Navigate to the desired URL
driver.get("https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php")

# Prompt for user input
input("Press Enter to exit...")

# Clean up
driver.quit()

Usage with Playwright

from playwright.sync_api import sync_playwright
from twocaptcha_extension_python import TwoCaptcha
import random

def generate_random_profile():
    return str(random.randint(1, 1000))

with sync_playwright() as p:
    extension_path = TwoCaptcha(api_key="TWO_CAPTCHA_KEY").load(with_command_line_option=False) # TODO: Replace with your own 2Captcha Key
    browser = p.chromium.launch_persistent_context(
        user_data_dir=generate_random_profile(),
        headless=False,
        args=[
            '--disable-extensions-except='+ extension_path,
            '--load-extension=' + extension_path,
        ],
    )
    page = browser.new_page()
    page.goto("https://recaptcha-demo.appspot.com/recaptcha-v2-checkbox.php")
    input("Press Enter to exit...")
    browser.close()

Love It? Star It ⭐!

Become one of our amazing stargazers by giving us a star ⭐ on GitHub!

It's just one click, but it means the world to me.

Stargazers for @omkarcloud/twocaptcha-extension-python

Metadata

Release files for twocaptcha-extension-python 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for twocaptcha-extension-python 1.0.1
File Size Uploaded
twocaptcha_extension_python-1.0.1.tar.gz 3.6 kB Details

Release files / twocaptcha_extension_python-1.0.1.tar.gz

Download URL twocaptcha_extension_python-1.0.1.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
57dd02efc275ba968a354ccf80b59b7c0dbdce4f0cc6743a44050996b14dee3e
BLAKE2b-256 checksum
How to use checksums
9edaa2cefc82ad579e12290538a1bf4dc5fff08cb92b997aea896470c1d983ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release history Release notifications | RSS feed

This release

1.0.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page