Skip to content

Commit 04b4439

Browse files
authored
Merge pull request #29 from captcha-solver-api/docs/improve-example-guides
docs: expand example usage guides
2 parents 63d710a + e3b5972 commit 04b4439

40 files changed

Lines changed: 428 additions & 116 deletions

‎examples/async/balance.py‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
"""
2-
Example: Get account balance with the async client.
1+
"""Example: Check the current Captcha Solver account balance without creating a CAPTCHA task.
2+
3+
What it does:
4+
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.
5+
6+
How it works:
7+
STEP-01 - Configure AsyncCaptchaClient with the API key.
8+
STEP-02 - Call await solver.get_balance(); this does not create or poll a CAPTCHA task.
9+
STEP-03 - Print the balance returned by the API.
310
411
Prerequisites:
512
Set the CAPTCHA_API_KEY environment variable.
6-
Returns the current available balance of your account.
713
"""
814

915
import asyncio

‎examples/async/coordinates.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
"""
2-
Example: Solve a click-based image captcha using CoordinatesTask with the async client.
1+
"""Example: Solve click-based image CAPTCHAs from bundled local images without a proxy.
2+
3+
What it does:
4+
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.
5+
6+
How it works:
7+
STEP-01 - Configure AsyncCaptchaClient with the API key.
8+
STEP-02 - Obtain the task parameters. The image, optional instruction image, and click hints come from examples/assets and this file.
9+
STEP-03 - Create CoordinatesTask and pass it to await solver.solve(task), which creates and polls the task.
10+
STEP-04 - Print pixel coordinates to click. Applying the solution and verifying acceptance are target-specific.
311
412
Prerequisites:
513
Set the CAPTCHA_API_KEY environment variable.

‎examples/async/geetest_v3_proxy.py‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,24 @@
1-
"""
2-
Example: Solve a GeeTest v3 challenge with the async client.
1+
"""Example: Solve GeeTest v3 through your own proxy.
2+
3+
What it does:
4+
This example shows how to solve GeeTest v3 through your own proxy. It uses GeeTestTask and AsyncCaptchaClient.solve(), returning challenge, validate, and seccode values.
5+
6+
How it works:
7+
STEP-01 - Configure AsyncCaptchaClient with the API key.
8+
STEP-02 - Obtain the task parameters. Extract the GeeTest values from the target page, fetch a fresh challenge, and provide your proxy settings.
9+
STEP-03 - Create GeeTestTask and pass it to await solver.solve(task), which creates and polls the task.
10+
STEP-04 - Print challenge, validate, and seccode values. Applying the solution and verifying acceptance are target-specific.
311
412
Prerequisites:
513
Set the CAPTCHA_API_KEY environment variable.
614
Replace websiteURL, gt, and challenge with values from your target page.
715
Important: the challenge value is dynamic. Fetch a fresh one for each request.
816
9-
NOTE: "https://target-site.com/path/to/geetest/init" below is a PLACEHOLDER, not a
10-
real endpoint -- this script will not run end-to-end as-is. Replace it with a request
11-
to your actual target page (or wherever it exposes a fresh `challenge` value) before
12-
running this example. It's here only to illustrate where that fetch belongs in the flow.
17+
NOTE: "https://target-site.com/path/to/geetest/init" below is a PLACEHOLDER, not a
18+
real endpoint -- this script will not run end-to-end as-is. Replace it with a request
19+
to your actual target page (or wherever it exposes a fresh `challenge` value) before
20+
running this example. It's here only to illustrate where that fetch belongs in the flow.
21+
Replace the proxy placeholders with your own proxy settings.
1322
"""
1423

1524
import asyncio

‎examples/async/geetest_v3_proxyless.py‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,23 @@
1-
"""
2-
Example: Solve a GeeTest v3 challenge with the async client.
1+
"""Example: Solve GeeTest v3 without a proxy.
2+
3+
What it does:
4+
This example shows how to solve GeeTest v3 without a proxy. It uses GeeTestTaskProxyless and AsyncCaptchaClient.solve(), returning challenge, validate, and seccode values.
5+
6+
How it works:
7+
STEP-01 - Configure AsyncCaptchaClient with the API key.
8+
STEP-02 - Obtain the task parameters. Extract websiteURL and gt from the target page and fetch a fresh challenge for every request.
9+
STEP-03 - Create GeeTestTaskProxyless and pass it to await solver.solve(task), which creates and polls the task.
10+
STEP-04 - Print challenge, validate, and seccode values. Applying the solution and verifying acceptance are target-specific.
311
412
Prerequisites:
513
Set the CAPTCHA_API_KEY environment variable.
614
Replace websiteURL, gt, and challenge with values from your target page.
715
Important: the challenge value is dynamic. Fetch a fresh one for each request.
816
9-
NOTE: "https://target-site.com/path/to/geetest/init" below is a PLACEHOLDER, not a
10-
real endpoint -- this script will not run end-to-end as-is. Replace it with a request
11-
to your actual target page (or wherever it exposes a fresh `challenge` value) before
12-
running this example. It's here only to illustrate where that fetch belongs in the flow.
17+
NOTE: "https://target-site.com/path/to/geetest/init" below is a PLACEHOLDER, not a
18+
real endpoint -- this script will not run end-to-end as-is. Replace it with a request
19+
to your actual target page (or wherever it exposes a fresh `challenge` value) before
20+
running this example. It's here only to illustrate where that fetch belongs in the flow.
1321
"""
1422

1523
import asyncio

‎examples/async/geetest_v4_proxy.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
"""
2-
Example: Solve a GeeTest v4 challenge with the async client.
1+
"""Example: Solve GeeTest v4 through your own proxy.
2+
3+
What it does:
4+
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.
5+
6+
How it works:
7+
STEP-01 - Configure AsyncCaptchaClient with the API key.
8+
STEP-02 - Obtain the task parameters. Extract websiteURL and captcha_id from the target page and provide your proxy settings.
9+
STEP-03 - Create GeeTestTask and pass it to await solver.solve(task), which creates and polls the task.
10+
STEP-04 - Print captcha_output and related validation fields. Applying the solution and verifying acceptance are target-specific.
311
412
Prerequisites:
513
Set the CAPTCHA_API_KEY environment variable.
614
Replace websiteURL and captcha_id with values from your target page.
715
GeeTest v4 drops gt/challenge entirely. It uses captcha_id instead, which
816
(unlike v3's challenge) is static per site, so it doesn't need to be
917
re-fetched for every request.
18+
Replace the proxy placeholders with your own proxy settings.
1019
"""
1120

1221
import asyncio

‎examples/async/geetest_v4_proxyless.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
"""
2-
Example: Solve a GeeTest v4 challenge with the async client.
1+
"""Example: Solve GeeTest v4 without a proxy.
2+
3+
What it does:
4+
This example shows how to solve GeeTest v4 without a proxy. It uses GeeTestTaskProxyless and AsyncCaptchaClient.solve(), returning captcha_output and related validation fields.
5+
6+
How it works:
7+
STEP-01 - Configure AsyncCaptchaClient with the API key.
8+
STEP-02 - Obtain the task parameters. Extract websiteURL and captcha_id from the target page.
9+
STEP-03 - Create GeeTestTaskProxyless and pass it to await solver.solve(task), which creates and polls the task.
10+
STEP-04 - Print captcha_output and related validation fields. Applying the solution and verifying acceptance are target-specific.
311
412
Prerequisites:
513
Set the CAPTCHA_API_KEY environment variable.

‎examples/async/image_to_text.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1-
"""
2-
Example: Solve an image captcha with the async client.
1+
"""Example: Recognize text in bundled local CAPTCHA images without a proxy.
2+
3+
What it does:
4+
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.
5+
6+
How it works:
7+
STEP-01 - Configure AsyncCaptchaClient with the API key.
8+
STEP-02 - Obtain the task parameters. The images and answer-format hints come from examples/assets and this file.
9+
STEP-03 - Create ImageToTextTask and pass it to await solver.solve(task), which creates and polls the task.
10+
STEP-04 - Print the recognized text. Applying the solution and verifying acceptance are target-specific.
311
412
Prerequisites:
513
Set the CAPTCHA_API_KEY environment variable.
614
Ready to run as-is: sample captcha images are bundled in examples/assets/.
15+
Use optional fields to give hints to the worker for faster solving.
716
"""
817

918
import asyncio

‎examples/async/recaptcha_v2_enterprise_proxy.py‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
"""
2-
Example: Solve a reCAPTCHA v2 Enterprise challenge with the async client.
1+
"""Example: Solve reCAPTCHA v2 Enterprise through your own proxy.
2+
3+
What it does:
4+
This example shows how to solve reCAPTCHA v2 Enterprise through your own proxy. It uses RecaptchaV2EnterpriseTask and AsyncCaptchaClient.solve(), returning a gRecaptchaResponse token.
5+
6+
How it works:
7+
STEP-01 - Configure AsyncCaptchaClient with the API key.
8+
STEP-02 - Obtain the task parameters. Extract websiteURL, websiteKey, and any enterprisePayload from the target page, and provide your proxy settings.
9+
STEP-03 - Create RecaptchaV2EnterpriseTask and pass it to await solver.solve(task), which creates and polls the task.
10+
STEP-04 - Print a gRecaptchaResponse token. Applying the solution and verifying acceptance are target-specific.
311
412
Prerequisites:
513
Set the CAPTCHA_API_KEY environment variable.
614
Replace websiteURL and websiteKey with values from your target page.
715
If the site uses enterprisePayload, extract and pass it or the token may be rejected.
16+
Replace the proxy placeholders with your own proxy settings.
817
"""
918

1019
import asyncio

‎examples/async/recaptcha_v2_enterprise_proxyless.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
"""
2-
Example: Solve a reCAPTCHA v2 Enterprise challenge with the async client.
1+
"""Example: Solve reCAPTCHA v2 Enterprise without a proxy.
2+
3+
What it does:
4+
This example shows how to solve reCAPTCHA v2 Enterprise without a proxy. It uses RecaptchaV2EnterpriseTaskProxyless and AsyncCaptchaClient.solve(), returning a gRecaptchaResponse token.
5+
6+
How it works:
7+
STEP-01 - Configure AsyncCaptchaClient with the API key.
8+
STEP-02 - Obtain the task parameters. Extract websiteURL, websiteKey, and any enterprisePayload from the target page.
9+
STEP-03 - Create RecaptchaV2EnterpriseTaskProxyless and pass it to await solver.solve(task), which creates and polls the task.
10+
STEP-04 - Print a gRecaptchaResponse token. Applying the solution and verifying acceptance are target-specific.
311
412
Prerequisites:
513
Set the CAPTCHA_API_KEY environment variable.

‎examples/async/recaptcha_v2_proxy.py‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
1-
"""
2-
Example: Solve a reCAPTCHA v2 challenge through your own proxy with the async client.
1+
"""Example: Solve reCAPTCHA v2 through your own proxy.
2+
3+
What it does:
4+
This example shows how to solve reCAPTCHA v2 through your own proxy. It uses RecaptchaV2Task and AsyncCaptchaClient.solve(), returning a gRecaptchaResponse token.
5+
6+
How it works:
7+
STEP-01 - Configure AsyncCaptchaClient with the API key.
8+
STEP-02 - Obtain the task parameters. Extract websiteURL and websiteKey from the target page and provide your proxy settings.
9+
STEP-03 - Create RecaptchaV2Task and pass it to await solver.solve(task), which creates and polls the task.
10+
STEP-04 - Print a gRecaptchaResponse token. Applying the solution and verifying acceptance are target-specific.
311
412
Prerequisites:
513
Set the CAPTCHA_API_KEY environment variable.

0 commit comments

Comments
 (0)