-
-
Save pwelch/4595c185ffb0a31a3e79a0c8d982e226 to your computer and use it in GitHub Desktop.
How to bypass Google reCaptcha v2 with Python Selenium and Capmonster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
from selenium.webdriver.chrome.options import Options | |
from webdriver_manager.chrome import ChromeDriverManager | |
from capmonster_python import NoCaptchaTaskProxyless | |
options = Options() | |
browser = webdriver.Chrome(options=options, executable_path=ChromeDriverManager().install()) | |
browser.get("https://www.google.com/recaptcha/api2/demo") | |
website_key = "6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-" | |
website_url = browser.current_url | |
captcha = NoCaptchaTaskProxyless(client_key="YOUR_CLIENT_KEY") | |
taskId = captcha.createTask(website_url, website_key) | |
print("# Task created successfully, waiting for the response.") | |
response = captcha.joinTaskResult(taskId) | |
print("# Response received.") | |
browser.execute_script(f"document.getElementsByClassName('g-recaptcha-response')[0].innerHTML = '{response}';") | |
print("# Response injected to secret input.") | |
browser.find_element_by_id("recaptcha-demo-submit").click() | |
print("# Form submitted.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment