admin管理员组

文章数量:1296246

We use enterprise anchor google image reCaptcha in our website and while automating it with our test framework(playwright and python) with this plugin, for the first few runs it's working but then the next few times either the image captcha is not getting resolved and just proceeds with the next line of code or fails and gives the below exception. I am seeing around only 70% accuracy while using this. Since our website uses enterprise anchor image reCaptcha i m using v2 recaptcha. Below is the implementation of it:

try:
        with recaptchav2.SyncSolver(page, capsolver_api_key=recaptcha_api_key) as solver:
            page.wait_for_timeout(int(random.uniform(5.57, 8.59) * 1000))
            token = solver.solve_recaptcha(wait=True, image_challenge=True)
            print(f"\n\n\n\nRecaptcha Token: {token}.\n\n\n\n")
    except Exception as e:  # Catch other unexpected exceptions
        print(f"\n\n\n\nAn unexpected error occurred: {e}\n\n\n\n")
        raise

# next line of code to verify the recaptcha is resovled

Error logs


E           playwright.\_impl.\_errors.Error: SyncSolver.solve_recaptcha: getaddrinfo ENOTFOUND www.google
E           Call log:
E           → GET ;k=6LdX518kAAAAAOW27hfHOIF8PqUA912D9DMKL5gV
E             -   user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/130.0.6723.31 Safari/537.36
E             -   accept: */*
E             -   accept-encoding: gzip,deflate,br
E             -   cookie: \_GRECAPTCHA=09AGVEItdxvV6zIQgIkFowqoG7ktUUCUIp6Z4XkQFmz7CcGPMtKCO36FKg6jE7TuD2tkSjV_FNjbSLJza9mcCUMUA

I have tried with different waits, looked over the github repo:

We use enterprise anchor google image reCaptcha in our website and while automating it with our test framework(playwright and python) with this plugin, for the first few runs it's working but then the next few times either the image captcha is not getting resolved and just proceeds with the next line of code or fails and gives the below exception. I am seeing around only 70% accuracy while using this. Since our website uses enterprise anchor image reCaptcha i m using v2 recaptcha. Below is the implementation of it:

try:
        with recaptchav2.SyncSolver(page, capsolver_api_key=recaptcha_api_key) as solver:
            page.wait_for_timeout(int(random.uniform(5.57, 8.59) * 1000))
            token = solver.solve_recaptcha(wait=True, image_challenge=True)
            print(f"\n\n\n\nRecaptcha Token: {token}.\n\n\n\n")
    except Exception as e:  # Catch other unexpected exceptions
        print(f"\n\n\n\nAn unexpected error occurred: {e}\n\n\n\n")
        raise

# next line of code to verify the recaptcha is resovled

Error logs


E           playwright.\_impl.\_errors.Error: SyncSolver.solve_recaptcha: getaddrinfo ENOTFOUND www.google
E           Call log:
E           → GET https://www.google/recaptcha/enterprise/payload?p=06AFcWeA5eUk2jyo2U3O3454gQDI4kxakHE0ZRqGSLM-O0RJzBw1EYpm1n3oWKR6WTvY-q2QKf236oBZNlg2jxP_lsPrQyTqDQi9iyhbX80I01gbH7gO7bFfKnIQujUpgUBlTJ-80PkRmtlJ6y5GZDlTAP13EN62mv-SETzsGYKgVrSThVOb-CVh1a4NCeN43_2_Xrq-sZNb5AraoxYrs5OIdwFKbZo335eA&k=6LdX518kAAAAAOW27hfHOIF8PqUA912D9DMKL5gV
E             -   user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/130.0.6723.31 Safari/537.36
E             -   accept: */*
E             -   accept-encoding: gzip,deflate,br
E             -   cookie: \_GRECAPTCHA=09AGVEItdxvV6zIQgIkFowqoG7ktUUCUIp6Z4XkQFmz7CcGPMtKCO36FKg6jE7TuD2tkSjV_FNjbSLJza9mcCUMUA

I have tried with different waits, looked over the github repo: https://github/Xewdy444/Playwright-reCAPTCHA/issues%60

Share Improve this question asked Feb 11 at 20:59 Yuvaraj KYuvaraj K 191 silver badge3 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I had a similar issue and found that CapSolver helped resolve it. Here's a simple code snippet using their API:

from caps_solver import SyncSolver

with SyncSolver(page, capsolver_api_key="your_api_key") as solver:
    token = solver.solve_recaptcha(wait=True)
    print(f"Recaptcha Token: {token}")

CapSolver supports a variety of captcha types and could improve the accuracy and reliability of your automation. Worth checking out!

本文标签: v2 reCaptcha from Playwrightrecaptch is inconsistentStack Overflow