Skip to main content

A library for solving reCAPTCHA v2 and v3 with Playwright

Project description

Python PyPI Downloads License



At the lowest price on the market, you may receive a variety of solutions, including reCAPTCHA v2, reCAPTCHA v3, hCaptcha, hCaptcha Click, FunCaptcha, picture-to-text, AWS Amazon CAPTCHA, and more. With this service, 0.1s is the slowest speed ever measured.

Playwright-reCAPTCHA

A Python library for solving reCAPTCHA v2 and v3 with Playwright.

Solving reCAPTCHA v2

reCAPTCHA v2 is solved by using the following methods:

  • Solving the audio challenge by transcribing the audio using the Google speech recognition API and entering the text as the response.
  • Solving the image challenge using the CapSolver API for image classification.

Solving reCAPTCHA v3

The solving of reCAPTCHA v3 is done by the browser itself, so this library simply waits for the browser to make a POST request to https://www.google.com/recaptcha/api2/reload or https://www.google.com/recaptcha/enterprise/reload and parses the response to get the g-recaptcha-response token.


All solvers return the g-recaptcha-response token, which is required for form submissions. If you are unsure about the version of reCAPTCHA being used, you can check out this blog post for more information.

Installation

pip install playwright-recaptcha

This library requires FFmpeg to be installed on your system in order to convert the audio challenge from reCAPTCHA v2 into text.

OS Command
Debian apt-get install ffmpeg
MacOS brew install ffmpeg
Windows winget install ffmpeg

You can also download the latest static build from here.

Note Make sure to have the ffmpeg and ffprobe binaries in your system's PATH so that the SpeechRecognition library can find them.

reCAPTCHA v2 Example

For more reCAPTCHA v2 examples, see the examples folder.

from playwright.sync_api import sync_playwright
from playwright_recaptcha import recaptchav2

with sync_playwright() as playwright:
    browser = playwright.firefox.launch()
    page = browser.new_page()
    page.goto("https://www.google.com/recaptcha/api2/demo")

    with recaptchav2.SyncSolver(page) as solver:
        token = solver.solve_recaptcha(wait=True)
        print(token)

If you would like to solve the image challenge, you can set the CAPSOLVER_API_KEY environment variable to your CapSolver API key. You can also pass the API key as an argument to recaptchav2.SyncSolver() with capsolver_api_key="your_api_key". Then, set image_challenge=True in solver.solve_recaptcha().

with recaptchav2.SyncSolver(page, capsolver_api_key="your_api_key") as solver:
    token = solver.solve_recaptcha(wait=True, image_challenge=True)
    print(token)

reCAPTCHA v3 Example

For more reCAPTCHA v3 examples, see the examples folder.

from playwright.sync_api import sync_playwright
from playwright_recaptcha import recaptchav3

with sync_playwright() as playwright:
    browser = playwright.firefox.launch()
    page = browser.new_page()

    with recaptchav3.SyncSolver(page) as solver:
        page.goto("https://antcpt.com/score_detector/")
        token = solver.solve_recaptcha()
        print(token)

It is best to initialize the solver before navigating to the page with the reCAPTCHA v3 challenge. This is because the solver adds a listener for the POST request to https://www.google.com/recaptcha/api2/reload or https://www.google.com/recaptcha/enterprise/reload and if the request is made before the listener is added, the g-recaptcha-response token will not be captured.

Disclaimer

This library is intended for use in automated testing and development environments only and should not be used for any illegal or malicious purposes. Any use of this library for activities that violate the terms of service of any website or service is strictly prohibited. The contributors of this library will not be held liable for any damages or legal issues that may arise from the use of this library. By using this library, you agree to these terms and take full responsibility for your actions.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

playwright-recaptcha-0.4.1.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

playwright_recaptcha-0.4.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file playwright-recaptcha-0.4.1.tar.gz.

File metadata

  • Download URL: playwright-recaptcha-0.4.1.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.6

File hashes

Hashes for playwright-recaptcha-0.4.1.tar.gz
Algorithm Hash digest
SHA256 56909e521e0114fcb8b5d93de44a3ae29a0c8bfa90c4bf5bd82327ac588cb0b4
MD5 3e25ead8b4bcb8127a3f6d7021384340
BLAKE2b-256 b689a4c2e43fb28c286546d13cb605079d21bbd54f3604cf06d85538e9fb7506

See more details on using hashes here.

File details

Details for the file playwright_recaptcha-0.4.1-py3-none-any.whl.

File metadata

File hashes

Hashes for playwright_recaptcha-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 053236bc7736d97c47b23888ac7ad8dc5e27c870805f4f1dbf11b2557add97ef
MD5 27423d4a5d9f8b76c9f49ffe5663b1e6
BLAKE2b-256 8d4a988d8d939813c64f03b5d4c6765816a9f680958a01c7530fa08d6265af84

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page