### Install RecaptchaDomainReplicator Source: https://github.com/dannyluna17/recaptchadomainreplicator/blob/main/README.md Installs the recaptcha-domain-replicator package using pip. Supports installation from source with development dependencies. ```bash pip install recaptcha-domain-replicator ``` ```bash pip install -e ".[dev]" ``` -------------------------------- ### Replicate Invisible reCAPTCHA with Proxy Authentication Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt Illustrates how to set up an invisible reCAPTCHA replica using a SOCKS5 proxy with username and password authentication. This example also shows how to specify a custom browser path and handle the token retrieval with a polling mechanism. ```python from recaptcha_domain_replicator import RecaptchaDomainReplicator # Initialize with SOCKS5 proxy with authentication replicator = RecaptchaDomainReplicator( download_dir="captcha_pages", server_port=8443, persist_html=True, proxy="socks5://username:password@proxy.example.com:1080", browser_path=r"C:\\Program Files\\Google\\Chrome for Testing\\chrome.exe" ) try: browser, token_handle = replicator.replicate_captcha( website_key="YOUR_SITE_KEY_HERE", website_url="https://example.com/login", is_invisible=True, action="login_submit", is_enterprise=False, bypass_domain_check=True, use_ssl=True ) if not browser: print("Failed to start browser session") else: # Poll for token with non-blocking get import time for i in range(60): token = token_handle.get() if token: print(f"Token obtained: {token}") break time.sleep(2) else: print("Timeout waiting for token") finally: replicator.close_browser() replicator.stop_http_server() ``` -------------------------------- ### Example Pull Request Branch Name Source: https://github.com/dannyluna17/recaptchadomainreplicator/blob/main/CONTRIBUTING.md Demonstrates the convention for naming branches when submitting a pull request. The format TYPE-ISSUE_ID-DESCRIPTION is used, where TYPE indicates the nature of the change (e.g., feat, doc, fix). ```bash doc-548-submit-a-pull-request-section-to-contribution-guide ``` -------------------------------- ### Execute reCAPTCHA Replication via CLI Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt This CLI command demonstrates advanced reCAPTCHA replication with full parameter control. It includes examples for basic replication and advanced configurations for invisible reCAPTCHA, proxy usage, domain bypass, enterprise features, and detailed logging. ```bash # Basic replication recaptcha-domain-replicator replicate \ --website-key "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-" \ --website-url "https://www.google.com/recaptcha/api2/demo" \ --observation-time 120 # Advanced: Invisible reCAPTCHA with proxy, domain bypass, and persistence recaptcha-domain-replicator replicate \ --website-key "YOUR_SITE_KEY" \ --website-url "https://example.com/page" \ --invisible \ --action "submit_form" \ --enterprise \ --api-domain "recaptcha.net" \ --data-s "CUSTOM_S_VALUE" \ --bypass-domain-check \ --proxy "socks5://user:pass@proxy.host:1080" \ --browser-path "C:\\path\\to\\chrome.exe" \ --persist-html \ --download-dir "output" \ --server-port 8443 \ --observation-time 0 \ --log-level INFO # Output: Prints the token to stdout if obtained # Exit code: 0 on success, 2 on failure, 130 on interrupt ``` -------------------------------- ### Manage Server and Browser Independently with Manual Control Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt This Python snippet demonstrates manual management of the server lifecycle and browser operations using RecaptchaDomainReplicator. It covers generating HTML pages, starting the HTTP server manually with specific domain and SSL configurations, and keeping the server alive for a defined duration. ```python from recaptcha_domain_replicator import RecaptchaDomainReplicator from recaptcha_domain_replicator.html_builder import create_captcha_html replicator = RecaptchaDomainReplicator( download_dir="pages", server_port=9090, persist_html=True ) # Generate HTML manually html_page = replicator.create_captcha_html( website_key="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", website_url="https://www.google.com/recaptcha/api2/demo", is_invisible=False, api_domain="google.com" ) print(f"HTML generated: {html_page.filename}") print(f"Path: {html_page.path}") print(f"Content length: {len(html_page.content)}") # Start server manually replicator.server.set_in_memory_html(html_page.filename, html_page.content) port = replicator.start_http_server(domain="www.google.com", use_ssl=True) print(f"Server running on port {port}") # Server will continue running until stopped import time time.sleep(300) # Keep server alive for 5 minutes ``` -------------------------------- ### Enterprise reCAPTCHA with Custom Data-s Parameter Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt Shows how to replicate an enterprise reCAPTCHA widget, specifying a custom `data-s` value and using the `recaptcha.net` API domain. This example includes waiting for a token with a specified timeout and handling the success or failure of token retrieval. ```python from recaptcha_domain_replicator import RecaptchaDomainReplicator import time replicator = RecaptchaDomainReplicator( download_dir="tmp", server_port=9000, persist_html=False ) # Enterprise reCAPTCHA with data-s value browser, token_handle = replicator.replicate_captcha( website_key="6LcENTERPRISE_KEY_HERE", website_url="https://corporate-site.com/form", is_invisible=False, data_s_value="CUSTOM_S_TOKEN_VALUE", api_domain="recaptcha.net", is_enterprise=True, bypass_domain_check=True, use_ssl=True ) if browser: # Wait with timeout and handle result token = token_handle.wait(timeout=180) if token and len(token) > 20: print(f"Valid enterprise token received") print(f"Token length: {len(token)} characters") # Use the token in your application # send_to_server(token) else: print("No valid token received") replicator.close_browser() replicator.stop_http_server() ``` -------------------------------- ### Utilize TokenHandle for Asynchronous Token Access Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt This Python snippet illustrates the usage of TokenHandle for accessing captured reCAPTCHA tokens asynchronously. It shows non-blocking checks using 'get()', blocking waits with timeouts using 'wait()', checking handle closure status with 'is_closed()', and manually closing the handle to stop monitoring. ```python from recaptcha_domain_replicator import RecaptchaDomainReplicator import time with RecaptchaDomainReplicator() as replicator: browser, token_handle = replicator.replicate_captcha( website_key="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", website_url="https://www.google.com/recaptcha/api2/demo" ) # Non-blocking check token = token_handle.get() if token: print(f"Token already available: {token}") else: print("Token not yet available") # Blocking wait with timeout (None or 0 = wait forever) token = token_handle.wait(timeout=60) if token: print(f"Token received: {token}") else: print("Timeout or handle closed without token") # Check if handle is closed if token_handle.is_closed(): print("Monitoring stopped") # Manually close handle to stop waiting token_handle.close() ``` -------------------------------- ### Run Demo using CLI Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt This command-line interface (CLI) command runs the built-in demo of the recaptcha-domain-replicator library, utilizing Google's test site key. It shows how to execute the demo with default settings and how to enable debug logging for more verbose output. ```bash # Run demo with default settings recaptcha-domain-replicator demo # Enable debug logging recaptcha-domain-replicator --log-level DEBUG demo ``` -------------------------------- ### CLI Usage for Recaptcha Replicator Source: https://github.com/dannyluna17/recaptchadomainreplicator/blob/main/README.md Shows how to use the RecaptchaDomainReplicator command-line interface to replicate a captcha. Includes options for persisting HTML, enabling invisibility, setting actions, bypassing domain checks, using proxies, specifying browser path, and observation time. ```bash recaptcha-domain-replicator --help ``` ```bash recaptcha-domain-replicator demo ``` ```bash recaptcha-domain-replicator replicate \ --website-key "YOUR_SITE_KEY" \ --website-url "https://example.com/path" \ --persist-html \ --invisible \ --action "submit" \ --bypass-domain-check \ --proxy "socks5://user:pass@host:port" \ --browser-path "C:\path\to\chrome.exe" \ --observation-time 0 ``` -------------------------------- ### Python Library Usage for Recaptcha Replicator Source: https://github.com/dannyluna17/recaptchadomainreplicator/blob/main/README.md Demonstrates how to use the RecaptchaDomainReplicator library in Python to replicate a reCAPTCHA widget and capture its token. It shows the instantiation of the replicator with various options and how to retrieve the token. ```python from recaptcha_domain_replicator import RecaptchaDomainReplicator with RecaptchaDomainReplicator( download_dir="tmp", server_port=8080, proxy=None, # "http://user:pass@host:port" browser_path=None, # r"C:\path\to\chrome.exe" ) as replicator: browser, token_handle = replicator.replicate_captcha( website_key="YOUR_SITE_KEY", website_url="https://example.com/path", is_invisible=True, action="submit", data_s_value=None, api_domain="google.com", # or "recaptcha.net" is_enterprise=False, bypass_domain_check=True, use_ssl=True, user_agent=None, cookies=None, browser=None, # already instanciated browser tab=None, ) # replicate_captcha() returns immediately, wait with the async token monitor token = token_handle.wait(timeout=120) if token_handle else None # 0 to wait until token is received print("Token:", token) ``` -------------------------------- ### Initialize and Use RecaptchaDomainReplicator with Existing Browser Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt This snippet demonstrates how to initialize the RecaptchaDomainReplicator, passing an existing browser instance and tab to the replicate_captcha method. It highlights how proxy settings are ignored and domain bypass falls back to hosts file modification when an existing browser is provided. The token is then retrieved by waiting on the token_handle. ```python from recaptcha_domain_replicator import RecaptchaDomainReplicator from pyppeteer import chromium # Create browser instance separately browser = chromium.Chromium() existing_tab = browser.latest_tab replicator = RecaptchaDomainReplicator( download_dir="tmp", server_port=8080 ) # Pass existing browser/tab to replicator browser_returned, token_handle = replicator.replicate_captcha( website_key="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", website_url="https://www.google.com/recaptcha/api2/demo", browser=browser, # or tab=existing_tab bypass_domain_check=False, use_ssl=False ) # Note: When passing existing browser, proxy settings are ignored # and domain bypass falls back to hosts file modification token = token_handle.wait(timeout=120) print(f"Token: {token}") # Don't close browser if you didn't create it replicator.stop_http_server() browser.quit() # Close manually ``` -------------------------------- ### Git Create New Branch Source: https://github.com/dannyluna17/recaptchadomainreplicator/blob/main/CONTRIBUTING.md Command to create a new branch from the current branch (typically 'main') and switch to it. Replace '[name_of_your_new_branch]' with a descriptive name following the project's convention. ```bash $ git checkout -b [name_of_your_new_branch] ``` -------------------------------- ### Enable Console Logging for Replicator in Python Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt Demonstrates how to enable console logging for the RecaptchaDomainReplicator library. This allows for detailed debugging and monitoring of operations, including server startup, CAPTCHA replication, and token handling. The logging level can be set to DEBUG, INFO, WARNING, ERROR, or CRITICAL. ```python from recaptcha_domain_replicator import RecaptchaDomainReplicator, enable_console_logging # Enable logging before operations enable_console_logging("DEBUG") # Levels: DEBUG, INFO, WARNING, ERROR, CRITICAL replicator = RecaptchaDomainReplicator( download_dir="tmp", server_port=8080, proxy="socks5://user:pass@proxy.example.com:1080" ) # All operations will now log detailed information browser, token_handle = replicator.replicate_captcha( website_key="YOUR_KEY", website_url="https://example.com", bypass_domain_check=True, use_ssl=True ) # Logs will show: # - Server startup and port binding # - SSL certificate generation # - Browser configuration # - Domain mapping rules # - Token monitoring progress # - Cleanup operations token = token_handle.wait(timeout=120) replicator.close() ``` -------------------------------- ### Basic RecaptchaDomainReplicator Usage Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt Demonstrates the fundamental usage of the RecaptchaDomainReplicator class within a context manager to replicate a visible reCAPTCHA widget and wait for a token. It showcases default parameters for directory, port, and proxy, and specifies options for the reCAPTCHA itself. ```python from recaptcha_domain_replicator import RecaptchaDomainReplicator # Basic usage with context manager with RecaptchaDomainReplicator( download_dir="tmp", server_port=8080, persist_html=False, proxy=None, browser_path=None ) as replicator: browser, token_handle = replicator.replicate_captcha( website_key="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", website_url="https://www.google.com/recaptcha/api2/demo", is_invisible=False, action=None, data_s_value=None, api_domain="google.com", is_enterprise=False, bypass_domain_check=True, use_ssl=True, user_agent=None, cookies=None, browser=None, tab=None ) # Wait for token (timeout=0 means wait indefinitely) token = token_handle.wait(timeout=120) if token: print(f"Token received: {token[:50]}...") else: print("No token obtained within timeout") ``` -------------------------------- ### Reuse Existing Browser Instance Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt This snippet demonstrates how to integrate RecaptchaDomainReplicator with an existing browser instance managed by DrissionPage. It allows reusing a pre-configured browser or tab, avoiding the overhead of creating new browser sessions for each replication. ```python from recaptcha_domain_replicator import RecaptchaDomainReplicator from DrissionPage import Chromium ``` -------------------------------- ### Parse and Format Proxy URLs in Python Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt Parses various proxy URL formats including schemes, authentication, and ports. It also provides a redacted format for sensitive information. This utility is crucial for setting up network proxies for the replicator. ```python from recaptcha_domain_replicator.proxy_utils import parse_proxy_url, format_proxy_redacted # Parse various proxy formats proxies = [ "http://proxy.example.com:8080", "https://user:pass@secure-proxy.com:8443", "socks5://username:password@socks.proxy.net:1080", "socks4://192.168.1.100:1080", "proxy.local:3128" # Assumes http if no scheme ] for proxy_str in proxies: try: proxy_config = parse_proxy_url(proxy_str) print(f"Scheme: {proxy_config.scheme}") print(f"Host: {proxy_config.host}") print(f"Port: {proxy_config.port}") print(f"Has credentials: {proxy_config.username is not None}") print(f"Redacted: {format_proxy_redacted(proxy_config)}") print("---") except ValueError as e: print(f"Invalid proxy '{proxy_str}': {e}") ``` -------------------------------- ### Git Push Changes Source: https://github.com/dannyluna17/recaptchadomainreplicator/blob/main/CONTRIBUTING.md Command to upload your committed changes from your local branch to the remote repository on GitHub. Replace '[name_of_your_new_branch]' with the name of the branch you are currently working on. ```bash $ git push origin [name_of_your_new_branch] ``` -------------------------------- ### Stop HTTP Server and Clean Up Resources in Python Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt This snippet shows how to stop the HTTP server and clean up any associated resources managed by the replicator. It's essential for graceful shutdown of the application. ```python # Assuming 'replicator' is an instance of RecaptchaDomainReplicator replicator.stop_http_server() print("Server stopped and resources cleaned up") ``` -------------------------------- ### Configure Custom User Agent and Cookies for reCAPTCHA Source: https://context7.com/dannyluna17/recaptchadomainreplicator/llms.txt This Python snippet shows how to configure custom user agent and cookies for a reCAPTCHA session using the RecaptchaDomainReplicator. It utilizes a 'with' statement for automatic resource management and demonstrates setting specific user agent strings and cookie dictionaries during the replication process. ```python from recaptcha_domain_replicator import RecaptchaDomainReplicator with RecaptchaDomainReplicator(download_dir="tmp") as replicator: custom_ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" custom_cookies = { "session_id": "abc123xyz", "preference": "dark_mode", "_ga": "GA1.2.123456789.987654321" } browser, token_handle = replicator.replicate_captcha( website_key="YOUR_SITE_KEY", website_url="https://example.com", user_agent=custom_ua, cookies=custom_cookies, bypass_domain_check=True, use_ssl=True ) token = token_handle.wait(timeout=90) if token: print(f"Token obtained with custom settings: {token[:40]}...") ``` -------------------------------- ### Git Pull Changes Source: https://github.com/dannyluna17/recaptchadomainreplicator/blob/main/CONTRIBUTING.md Command to fetch and merge changes from the upstream repository's main branch into your local main branch. This ensures your local repository is up-to-date before creating a new branch. ```bash $ git pull ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.