Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions examples/async/balance.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
"""
Example: Get account balance with the async client.
"""Example: Check the current Captcha Solver account balance without creating a CAPTCHA task.

What it does:
This example shows how to check the current Captcha Solver account balance without creating a CAPTCHA task. It uses AsyncCaptchaClient.get_balance() and returns the account balance.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Call await solver.get_balance(); this does not create or poll a CAPTCHA task.
STEP-03 - Print the balance returned by the API.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Returns the current available balance of your account.
"""

import asyncio
Expand All @@ -25,10 +31,10 @@
from captcha_solver_api import AsyncCaptchaClient

# in this example we store the API key inside environment variables that can be set like:
# export CAPTCHA_API_KEY=1abc234de56fab7c89012d34e56fa7b8 on Linux or macOS
# set CAPTCHA_API_KEY=1abc234de56fab7c89012d34e56fa7b8 on Windows
# export CAPTCHA_API_KEY=your_api_key on Linux or macOS
# set CAPTCHA_API_KEY=your_api_key on Windows
# you can just set the API key directly to its value like:
# api_key="1abc234de56fab7c89012d34e56fa7b8"
# api_key="your_api_key"

api_key = os.getenv("CAPTCHA_API_KEY", "YOUR_API_KEY")

Expand Down
12 changes: 10 additions & 2 deletions examples/async/coordinates.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Example: Solve a click-based image captcha using CoordinatesTask with the async client.
"""Example: Solve click-based image CAPTCHAs from bundled local images without a proxy.

What it does:
This example shows how to solve click-based image CAPTCHAs from bundled local images without a proxy. It uses CoordinatesTask and AsyncCaptchaClient.solve(), returning pixel coordinates to click.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. The image, optional instruction image, and click hints come from examples/assets and this file.
STEP-03 - Create CoordinatesTask and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print pixel coordinates to click. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Expand Down
21 changes: 15 additions & 6 deletions examples/async/geetest_v3_proxy.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
"""
Example: Solve a GeeTest v3 challenge with the async client.
"""Example: Solve GeeTest v3 through your own proxy.

What it does:
This example shows how to solve GeeTest v3 through your own proxy. It uses GeeTestTask and AsyncCaptchaClient.solve(), returning challenge, validate, and seccode values.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract the GeeTest values from the target page, fetch a fresh challenge, and provide your proxy settings.
STEP-03 - Create GeeTestTask and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print challenge, validate, and seccode values. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Replace websiteURL, gt, and challenge with values from your target page.
Important: the challenge value is dynamic. Fetch a fresh one for each request.

NOTE: "https://target-site.com/path/to/geetest/init" below is a PLACEHOLDER, not a
real endpoint -- this script will not run end-to-end as-is. Replace it with a request
to your actual target page (or wherever it exposes a fresh `challenge` value) before
running this example. It's here only to illustrate where that fetch belongs in the flow.
NOTE: "https://target-site.com/path/to/geetest/init" below is a PLACEHOLDER, not a
real endpoint -- this script will not run end-to-end as-is. Replace it with a request
to your actual target page (or wherever it exposes a fresh `challenge` value) before
running this example. It's here only to illustrate where that fetch belongs in the flow.
Replace the proxy placeholders with your own proxy settings.
"""

import asyncio
Expand Down
20 changes: 14 additions & 6 deletions examples/async/geetest_v3_proxyless.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
"""
Example: Solve a GeeTest v3 challenge with the async client.
"""Example: Solve GeeTest v3 without a proxy.

What it does:
This example shows how to solve GeeTest v3 without a proxy. It uses GeeTestTaskProxyless and AsyncCaptchaClient.solve(), returning challenge, validate, and seccode values.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL and gt from the target page and fetch a fresh challenge for every request.
STEP-03 - Create GeeTestTaskProxyless and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print challenge, validate, and seccode values. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Replace websiteURL, gt, and challenge with values from your target page.
Important: the challenge value is dynamic. Fetch a fresh one for each request.

NOTE: "https://target-site.com/path/to/geetest/init" below is a PLACEHOLDER, not a
real endpoint -- this script will not run end-to-end as-is. Replace it with a request
to your actual target page (or wherever it exposes a fresh `challenge` value) before
running this example. It's here only to illustrate where that fetch belongs in the flow.
NOTE: "https://target-site.com/path/to/geetest/init" below is a PLACEHOLDER, not a
real endpoint -- this script will not run end-to-end as-is. Replace it with a request
to your actual target page (or wherever it exposes a fresh `challenge` value) before
running this example. It's here only to illustrate where that fetch belongs in the flow.
"""

import asyncio
Expand Down
13 changes: 11 additions & 2 deletions examples/async/geetest_v4_proxy.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
"""
Example: Solve a GeeTest v4 challenge with the async client.
"""Example: Solve GeeTest v4 through your own proxy.

What it does:
This example shows how to solve GeeTest v4 through your own proxy. It uses GeeTestTask and AsyncCaptchaClient.solve(), returning captcha_output and related validation fields.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL and captcha_id from the target page and provide your proxy settings.
STEP-03 - Create GeeTestTask and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print captcha_output and related validation fields. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Replace websiteURL and captcha_id with values from your target page.
GeeTest v4 drops gt/challenge entirely. It uses captcha_id instead, which
(unlike v3's challenge) is static per site, so it doesn't need to be
re-fetched for every request.
Replace the proxy placeholders with your own proxy settings.
"""

import asyncio
Expand Down
12 changes: 10 additions & 2 deletions examples/async/geetest_v4_proxyless.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Example: Solve a GeeTest v4 challenge with the async client.
"""Example: Solve GeeTest v4 without a proxy.

What it does:
This example shows how to solve GeeTest v4 without a proxy. It uses GeeTestTaskProxyless and AsyncCaptchaClient.solve(), returning captcha_output and related validation fields.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL and captcha_id from the target page.
STEP-03 - Create GeeTestTaskProxyless and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print captcha_output and related validation fields. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Expand Down
13 changes: 11 additions & 2 deletions examples/async/image_to_text.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
"""
Example: Solve an image captcha with the async client.
"""Example: Recognize text in bundled local CAPTCHA images without a proxy.

What it does:
This example shows how to recognize text in bundled local CAPTCHA images without a proxy. It uses ImageToTextTask and AsyncCaptchaClient.solve(), returning the recognized text.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. The images and answer-format hints come from examples/assets and this file.
STEP-03 - Create ImageToTextTask and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print the recognized text. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Ready to run as-is: sample captcha images are bundled in examples/assets/.
Use optional fields to give hints to the worker for faster solving.
"""

import asyncio
Expand Down
13 changes: 11 additions & 2 deletions examples/async/recaptcha_v2_enterprise_proxy.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
"""
Example: Solve a reCAPTCHA v2 Enterprise challenge with the async client.
"""Example: Solve reCAPTCHA v2 Enterprise through your own proxy.

What it does:
This example shows how to solve reCAPTCHA v2 Enterprise through your own proxy. It uses RecaptchaV2EnterpriseTask and AsyncCaptchaClient.solve(), returning a gRecaptchaResponse token.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL, websiteKey, and any enterprisePayload from the target page, and provide your proxy settings.
STEP-03 - Create RecaptchaV2EnterpriseTask and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print a gRecaptchaResponse token. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Replace websiteURL and websiteKey with values from your target page.
If the site uses enterprisePayload, extract and pass it or the token may be rejected.
Replace the proxy placeholders with your own proxy settings.
"""

import asyncio
Expand Down
12 changes: 10 additions & 2 deletions examples/async/recaptcha_v2_enterprise_proxyless.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Example: Solve a reCAPTCHA v2 Enterprise challenge with the async client.
"""Example: Solve reCAPTCHA v2 Enterprise without a proxy.

What it does:
This example shows how to solve reCAPTCHA v2 Enterprise without a proxy. It uses RecaptchaV2EnterpriseTaskProxyless and AsyncCaptchaClient.solve(), returning a gRecaptchaResponse token.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL, websiteKey, and any enterprisePayload from the target page.
STEP-03 - Create RecaptchaV2EnterpriseTaskProxyless and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print a gRecaptchaResponse token. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Expand Down
12 changes: 10 additions & 2 deletions examples/async/recaptcha_v2_proxy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Example: Solve a reCAPTCHA v2 challenge through your own proxy with the async client.
"""Example: Solve reCAPTCHA v2 through your own proxy.

What it does:
This example shows how to solve reCAPTCHA v2 through your own proxy. It uses RecaptchaV2Task and AsyncCaptchaClient.solve(), returning a gRecaptchaResponse token.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL and websiteKey from the target page and provide your proxy settings.
STEP-03 - Create RecaptchaV2Task and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print a gRecaptchaResponse token. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Expand Down
12 changes: 10 additions & 2 deletions examples/async/recaptcha_v2_proxyless.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Example: Solve a reCAPTCHA v2 challenge without a proxy with the async client.
"""Example: Solve reCAPTCHA v2 without a proxy.

What it does:
This example shows how to solve reCAPTCHA v2 without a proxy. It uses RecaptchaV2TaskProxyless and AsyncCaptchaClient.solve(), returning a gRecaptchaResponse token.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL and websiteKey from the target page.
STEP-03 - Create RecaptchaV2TaskProxyless and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print a gRecaptchaResponse token. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Expand Down
18 changes: 13 additions & 5 deletions examples/async/recaptcha_v3.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
"""
Example: Solve a reCAPTCHA v3 challenge with the async client.
"""Example: Solve score-based reCAPTCHA v3 without a proxy.

What it does:
This example shows how to solve score-based reCAPTCHA v3 without a proxy. It uses RecaptchaV3TaskProxyless and AsyncCaptchaClient.solve(), returning a gRecaptchaResponse token.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL, websiteKey, and pageAction from the target page, then choose the required minimum score.
STEP-03 - Create RecaptchaV3TaskProxyless and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print a gRecaptchaResponse token. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Replace websiteURL, websiteKey, and minScore with values from your target
page, and pass pageAction if the site uses it -- this increases the
chance of the token being accepted.
Replace websiteURL and websiteKey with values from your target page, pass
pageAction if the site uses it, and choose the minimum score your
integration requires.
"""

import asyncio
Expand Down
13 changes: 11 additions & 2 deletions examples/async/tencent_proxy.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
"""
Example: Solve a Tencent captcha challenge with the async client.
"""Example: Solve Tencent CAPTCHA through your own proxy.

What it does:
This example shows how to solve Tencent CAPTCHA through your own proxy. It uses TencentTask and AsyncCaptchaClient.solve(), returning appid, ret, ticket, and randstr values.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL, appId, and any non-default captchaScript from the target page, then provide your proxy settings.
STEP-03 - Create TencentTask and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print appid, ret, ticket, and randstr values. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Replace websiteURL and appId with values from your target page.
Pass captchaScript if the site uses a non-default script URL.
Replace the proxy placeholders with your own proxy settings.
"""

import asyncio
Expand Down
12 changes: 10 additions & 2 deletions examples/async/tencent_proxyless.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Example: Solve a Tencent captcha challenge with the async client.
"""Example: Solve Tencent CAPTCHA without a proxy.

What it does:
This example shows how to solve Tencent CAPTCHA without a proxy. It uses TencentTaskProxyless and AsyncCaptchaClient.solve(), returning appid, ret, ticket, and randstr values.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL, appId, and any non-default captchaScript from the target page.
STEP-03 - Create TencentTaskProxyless and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print appid, ret, ticket, and randstr values. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Expand Down
13 changes: 11 additions & 2 deletions examples/async/turnstile_proxy.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
"""
Example: Solve a Cloudflare Turnstile challenge with the async client.
"""Example: Solve Cloudflare Turnstile through your own proxy.

What it does:
This example shows how to solve Cloudflare Turnstile through your own proxy. It uses TurnstileTask and AsyncCaptchaClient.solve(), returning a token.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL, websiteKey, and any Challenge-page action, data, and pagedata values, then provide your proxy settings.
STEP-03 - Create TurnstileTask and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print a token. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Replace websiteURL and websiteKey with values from your target page.
For Cloudflare Challenge pages, also extract and pass action, data, and pagedata.
Replace the proxy placeholders with your own proxy settings.
"""

import asyncio
Expand Down
12 changes: 10 additions & 2 deletions examples/async/turnstile_proxyless.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
"""
Example: Solve a Cloudflare Turnstile challenge with the async client.
"""Example: Solve Cloudflare Turnstile without a proxy.

What it does:
This example shows how to solve Cloudflare Turnstile without a proxy. It uses TurnstileTaskProxyless and AsyncCaptchaClient.solve(), returning a token.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. Extract websiteURL, websiteKey, and any Challenge-page action, data, and pagedata values from the target page.
STEP-03 - Create TurnstileTaskProxyless and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print a token. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Expand Down
11 changes: 10 additions & 1 deletion examples/async/yandex_smartcaptcha_image.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
"""Example: Solve an image-based Yandex SmartCaptcha asynchronously.
"""Example: Solve an image-based Yandex SmartCaptcha from bundled local images without a proxy.

What it does:
This example shows how to solve an image-based Yandex SmartCaptcha from bundled local images without a proxy. It uses YandexSmartCaptchaImageTask and AsyncCaptchaClient.solve(), returning pixel coordinates to click.

How it works:
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. The challenge and instruction images come from examples/assets.
STEP-03 - Create YandexSmartCaptchaImageTask and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print pixel coordinates to click. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Expand Down
16 changes: 7 additions & 9 deletions examples/async/yandex_smartcaptcha_kaleidoscope.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"""Example: Solve an image-based Yandex SmartCaptcha Kaleidoscope asynchronously.
"""Example: Solve a Yandex SmartCaptcha Kaleidoscope puzzle from a bundled local image without a proxy.

This example reads the bundled Kaleidoscope challenge image, encodes it as
Base64, sends it together with the puzzle-step sequence without a proxy, and
prints how many times to click the slider arrow. It uses
YandexSmartCaptchaKaleidoscopeTask and AsyncCaptchaClient.solve().
What it does:
This example shows how to solve a Yandex SmartCaptcha Kaleidoscope puzzle from a bundled local image without a proxy. It uses YandexSmartCaptchaKaleidoscopeTask and AsyncCaptchaClient.solve(), returning the number of slider-arrow clicks.

How it works:
STEP-01 - Configure AsyncCaptchaClient and locate the bundled challenge image.
STEP-02 - Encode the image and create a task with the captured puzzle steps.
STEP-03 - Await solve(), which creates the task and polls for its solution.
STEP-04 - Print the slider-arrow click count, or report the error.
STEP-01 - Configure AsyncCaptchaClient with the API key.
STEP-02 - Obtain the task parameters. The challenge image comes from examples/assets and the puzzle-step sequence is captured from the challenge.
STEP-03 - Create YandexSmartCaptchaKaleidoscopeTask and pass it to await solver.solve(task), which creates and polls the task.
STEP-04 - Print the number of slider-arrow clicks. Applying the solution and verifying acceptance are target-specific.

Prerequisites:
Set the CAPTCHA_API_KEY environment variable.
Expand Down
Loading
Loading