From 8e1e80b8c84d3fcd9a769ee0e2c3d247a1a4ee9b Mon Sep 17 00:00:00 2001 From: dariyaanis Date: Thu, 1 Oct 2026 18:26:59 +0300 Subject: [PATCH 1/2] fix: support standard reCAPTCHA demo markup --- examples/recaptcha_v2.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/examples/recaptcha_v2.py b/examples/recaptcha_v2.py index 3370728..942588f 100644 --- a/examples/recaptcha_v2.py +++ b/examples/recaptcha_v2.py @@ -3,12 +3,19 @@ import time from captcha_solver_api.tasks import RecaptchaV2TaskProxyless -from common import create_client, fill_response_field, required_env, show_success, wait_for_xpath +from common import ( + create_client, + fill_response_field, + required_env, + wait_for_css, + wait_for_xpath, +) from seleniumbase import Driver URL = required_env("TARGET_URL") -SITEKEY_LOCATOR = "//div[@id='g-recaptcha']" -SUBMIT_LOCATOR = "//button[@data-action='demo_action']" +SITEKEY_LOCATOR = "//*[@data-sitekey]" +SUBMIT_LOCATOR = "//*[@type='submit']" +SUCCESS_SELECTOR = ".recaptcha-success, p.successMessage" def main() -> None: @@ -28,7 +35,7 @@ def main() -> None: ) fill_response_field(driver, "g-recaptcha-response", solution["gRecaptchaResponse"]) wait_for_xpath(driver, SUBMIT_LOCATOR).click() - show_success(driver) + print(wait_for_css(driver, SUCCESS_SELECTOR).text) time.sleep(5) From 0d6e68e1c9871c5a98e32cff5361593f787f6888 Mon Sep 17 00:00:00 2001 From: dariyaanis Date: Thu, 1 Oct 2026 18:31:47 +0300 Subject: [PATCH 2/2] docs: add ready-to-run reCAPTCHA demo --- README.md | 17 +++++++++++++---- examples/recaptcha_v2.py | 4 ++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index abd2e38..8a12b41 100644 --- a/README.md +++ b/README.md @@ -74,10 +74,19 @@ CAPTCHA_API_KEY=your_api_key TARGET_URL=https://your-site.example/captcha-page ``` -> Before running an example, replace `TARGET_URL` with the target page for your -> own authorized test. Do not leave the placeholder value. Each example expects -> the page to contain the corresponding captcha type and may require its -> selectors or callback names to be adjusted for that page. +> Before running an example other than `recaptcha_v2.py`, replace `TARGET_URL` +> with the target page for your own authorized test. Do not leave the placeholder +> value. Each example expects the page to contain the corresponding captcha type +> and may require its selectors or callback names to be adjusted for that page. + +The reCAPTCHA v2 example is ready to run without setting `TARGET_URL`: + +```bash +python examples/recaptcha_v2.py +``` + +It uses the official public reCAPTCHA demo by default. Set `TARGET_URL` only if +you want to run it against another authorized page. Run an example from the repository root: diff --git a/examples/recaptcha_v2.py b/examples/recaptcha_v2.py index 942588f..f1c013d 100644 --- a/examples/recaptcha_v2.py +++ b/examples/recaptcha_v2.py @@ -1,18 +1,18 @@ """Solve reCAPTCHA v2 in a SeleniumBase browser session.""" +import os import time from captcha_solver_api.tasks import RecaptchaV2TaskProxyless from common import ( create_client, fill_response_field, - required_env, wait_for_css, wait_for_xpath, ) from seleniumbase import Driver -URL = required_env("TARGET_URL") +URL = os.getenv("TARGET_URL") or "https://www.google.com/recaptcha/api2/demo" SITEKEY_LOCATOR = "//*[@data-sitekey]" SUBMIT_LOCATOR = "//*[@type='submit']" SUCCESS_SELECTOR = ".recaptcha-success, p.successMessage"