From 74aab1d7a124cf27a85090d83414f1f5e42a6091 Mon Sep 17 00:00:00 2001 From: dzmitry-duboyski Date: Mon, 17 Jun 2024 13:29:52 +0400 Subject: [PATCH 1/6] Add examples to README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index cb17190..4f40712 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ The easiest way to quickly integrate the 2Captcha captcha-solving service into y - [Error handling](#error-handling) - [Proxies](#proxies) - [Async calls](#async-calls) + - [Examples](#examples) ## Installation @@ -388,6 +389,8 @@ async def captchaSolver(image): captcha_result = asyncio.run(captchaSolver(image)) ``` +## Examples +Examples of solving all supported captcha types are located in the [examples] directory. [2Captcha]: https://2captcha.com/ @@ -399,3 +402,4 @@ captcha_result = asyncio.run(captchaSolver(image)) [asyncio]: https://docs.python.org/3/library/asyncio.html [Buy residential proxies]: https://2captcha.com/proxy/residential-proxies [Quick start]: https://2captcha.com/proxy?openAddTrafficModal=true +[examples]: ./examples From ca60a354d347bf9ce8160f6a7ac36b0031fd252f Mon Sep 17 00:00:00 2001 From: Maxim S Date: Mon, 17 Jun 2024 11:31:53 +0200 Subject: [PATCH 2/6] - Added a description for the send method and an example of manually sending a captcha for send to README.md - Added description of the method parameter for send() in solver.py Signed-off-by: Maxim S --- README.md | 17 ++++++++++++++++- twocaptcha/solver.py | 4 +++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cb17190..6429075 100644 --- a/README.md +++ b/README.md @@ -309,7 +309,11 @@ result = solver.tencent(app_id="197326679", ## Other methods ### send / get_result -These methods can be used for manual captcha submission and answer polling. +These methods can be used for manual captcha submission and answer polling. The `send()` method supports sending any captcha +type, to specify the captcha type you must send value `method` manually, for example `method='hcaptcha'` for solving hCapthca. +You can find the value of the `method` parameter in the [API documentation](https://2captcha.com/2captcha-api). + +Example for solving Normal captcha manually: ```python import time . . . . . @@ -318,6 +322,17 @@ import time id = solver.send(file='path/to/captcha.jpg') time.sleep(20) +code = solver.get_result(id) +``` +Example for solving hCaptcha manually: +```python +import time +. . . . . +id = solver.send(sitekey='41b778e7-8f20-45cc-a804-1f1ebb45c579', + url='https://2captcha.com/demo/hcaptcha?difficulty=easy', + method='hcaptcha') +print(id) +time.sleep(20) code = solver.get_result(id) ``` diff --git a/twocaptcha/solver.py b/twocaptcha/solver.py index 038751b..e40f0ff 100755 --- a/twocaptcha/solver.py +++ b/twocaptcha/solver.py @@ -879,8 +879,10 @@ def send(self, **kwargs): Parameters _________ + method : str + The name of the method must be found in the documentation https://2captcha.com/2captcha-api kwargs: dict - + All captcha params Returns """ From fc77eba3af69ba49a4cbff87cc3b4eb018e8a603 Mon Sep 17 00:00:00 2001 From: Maksim S Date: Mon, 17 Jun 2024 13:16:07 +0200 Subject: [PATCH 3/6] RC-2749-add-links-to-documentation (#93) * - Added links to API documentation to methods in README.md Signed-off-by: Maxim S * - Links are wrapped in sup tag Signed-off-by: Maxim S --------- Signed-off-by: Maxim S Co-authored-by: Victor --- README.md | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/README.md b/README.md index dc3a07c..ed959c1 100644 --- a/README.md +++ b/README.md @@ -103,6 +103,8 @@ When you submit any image-based captcha use can provide additional options to he Below you can find basic examples for every captcha type. Check out [examples directory] to find more examples with all available options. ### Normal Captcha +[API method description.](https://2captcha.com/2captcha-api#solving_normal_captcha) + To bypass a normal captcha (distorted text on an image) use the following method. This method also can be used to recognize any text on the image. ```python result = solver.normal('path/to/captcha.jpg', param1=..., ...) @@ -111,6 +113,9 @@ result = solver.normal('https://site-with-captcha.com/path/to/captcha.jpg', para ``` ### Audio Captcha + +[API method description.](https://2captcha.com/2captcha-api#audio) + To bypass an audio captcha (mp3 formats only) use the following method. You must provide the language as `lang = 'en'`. Supported languages are "en", "ru", "de", "el", "pt", "fr". @@ -121,12 +126,18 @@ result = solver.audio('https://site-with-captcha.com/path/to/captcha.mp3', lang ``` ### Text Captcha + +[API method description.](https://2captcha.com/2captcha-api#solving_text_captcha) + This method can be used to bypass a captcha that requires answering a question provided in clear text. ```python result = solver.text('If tomorrow is Saturday, what day is today?', param1=..., ...) ``` ### reCAPTCHA v2 + +[API method description.](https://2captcha.com/2captcha-api#solving_recaptchav2_new) + Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection. ```python result = solver.recaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', @@ -135,6 +146,9 @@ result = solver.recaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', ``` ### reCAPTCHA v3 + +[API method description.](https://2captcha.com/2captcha-api#solving_recaptchav3) + This method provides a reCAPTCHA V3 solver and returns a token. ```python result = solver.recaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', @@ -144,6 +158,9 @@ result = solver.recaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', ``` ### FunCaptcha + +[API method description.](https://2captcha.com/2captcha-api#solving_funcaptcha_new) + FunCaptcha (Arkoselabs) solving method. Returns a token. ```python result = solver.funcaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', @@ -154,6 +171,9 @@ result = solver.funcaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', ### GeeTest + +[API method description.](https://2captcha.com/2captcha-api#solving_geetest) + Method to solve GeeTest puzzle captcha. Returns a set of tokens as JSON. ```python result = solver.geetest(gt='f1ab2cdefa3456789012345b6c78d90e', @@ -165,6 +185,9 @@ result = solver.geetest(gt='f1ab2cdefa3456789012345b6c78d90e', ### GeeTest v4 + +[API method description.](https://2captcha.com/2captcha-api#geetest-v4) + Use this method to solve GeeTest v4. Returns the response in JSON. ```python result = solver.geetest_v4(captcha_id='e392e1d7fd421dc63325744d5a2b9c73', @@ -175,6 +198,9 @@ result = solver.geetest_v4(captcha_id='e392e1d7fd421dc63325744d5a2b9c73', ### hCaptcha + +[API method description.](https://2captcha.com/2captcha-api#solving_hcaptcha) + Use this method to solve the hCaptcha challenge. Returns a token to bypass the captcha. ```python result = solver.hcaptcha(sitekey='10000000-ffff-ffff-ffff-000000000001', @@ -185,6 +211,9 @@ result = solver.hcaptcha(sitekey='10000000-ffff-ffff-ffff-000000000001', ### Lemin Cropped Captcha + +[API method description.](https://2captcha.com/2captcha-api#lemin) + Use this method to solve hCaptcha challenge. Returns JSON with an answer containing the following values: answer, challenge_id. ```python result = solver.lemin(captcha_id='CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d901d', @@ -196,6 +225,9 @@ result = solver.lemin(captcha_id='CROPPED_1abcd2f_a1234b567c890d12ef3a456bc78d90 ### Cloudflare Turnstile + +[API method description.](https://2captcha.com/2captcha-api#turnstile) + Use this method to solve Cloudflare Turnstile. Returns JSON with the token. ```python result = solver.turnstile(sitekey='0x1AAAAAAAAkg0s2VIOD34y5', @@ -207,6 +239,9 @@ result = solver.turnstile(sitekey='0x1AAAAAAAAkg0s2VIOD34y5', ``` ### Amazon WAF + +[API method description.](https://2captcha.com/2captcha-api#amazon-waf) + Use this method to solve Amazon WAF Captcha also known as AWS WAF Captcha is a part of Intelligent threat mitigation for Amazon AWS. Returns JSON with the token. ```python result = solver.amazon_waf(sitekey='0x1AAAAAAAAkg0s2VIOD34y5', @@ -219,6 +254,9 @@ result = solver.amazon_waf(sitekey='0x1AAAAAAAAkg0s2VIOD34y5', ### KeyCaptcha + +[API method description.](https://2captcha.com/2captcha-api#solving_keycaptcha) + Token-based method to solve KeyCaptcha. ```python result = solver.keycaptcha(s_s_c_user_id=10, @@ -232,6 +270,9 @@ result = solver.keycaptcha(s_s_c_user_id=10, ### atbCAPTCHA + +[API method description.](https://2captcha.com/2captcha-api#atb-captcha) + Use this method to solve atbCaptcha challenge. Returns a token to bypass the captcha. ```python result = solver.atb_captcha(app_id='af25e409b33d722a95e56a230ff8771c', @@ -243,6 +284,9 @@ result = solver.atb_captcha(app_id='af25e409b33d722a95e56a230ff8771c', ### Capy + +[API method description.](https://2captcha.com/2captcha-api#solving_capy) + Token-based method to bypass Capy puzzle captcha. ```python result = solver.capy(sitekey='PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v', @@ -251,30 +295,45 @@ result = solver.capy(sitekey='PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v', param1=..., ...) ``` ### Grid + +[API method description.](https://2captcha.com/2captcha-api#grid) + Grid method was originally called the Old reCAPTCHA V2 method. The method can be used to bypass any type of captcha where you can apply a grid on an image and click specific grid boxes. Returns numbers of boxes. ```python result = solver.grid('path/to/captcha.jpg', param1=..., ...) ``` ### Canvas + +[API method description.](https://2captcha.com/2captcha-api#canvas) + Canvas method can be used when you need to draw a line around an object on an image. Returns a set of points' coordinates to draw a polygon. ```python result = solver.canvas('path/to/captcha.jpg', param1=..., ...) ``` ### ClickCaptcha + +[API method description.](https://2captcha.com/2captcha-api#coordinates) + ClickCaptcha method returns coordinates of points on the captcha image. Can be used if you need to click on particular points in the image. ```python result = solver.coordinates('path/to/captcha.jpg', param1=..., ...) ``` ### Rotate + +[API method description.](https://2captcha.com/2captcha-api#solving_rotatecaptcha) + This method can be used to solve a captcha that asks to rotate an object. Mostly used to bypass FunCaptcha. Returns the rotation angle. ```python result = solver.rotate('path/to/captcha.jpg', param1=..., ...) ``` ### MTCaptcha + +[API method description.](https://2captcha.com/2captcha-api#mtcaptcha) + Use this method to solve MTCaptcha and obtain a token to bypass the protection. ```python result = solver.mtcaptcha(sitekey='MTPublic-KzqLY1cKH', @@ -283,6 +342,9 @@ result = solver.mtcaptcha(sitekey='MTPublic-KzqLY1cKH', ``` ### Friendly Captcha + +[API method description.](https://2captcha.com/2captcha-api#friendly-captcha) + Friendly Captcha solving method. Returns a token. ```python result = solver.friendly_captcha(sitekey='FCMGEMUD2KTDSQ5H', @@ -291,6 +353,9 @@ result = solver.friendly_captcha(sitekey='FCMGEMUD2KTDSQ5H', ``` ### Cutcaptcha + +[API method description.](https://2captcha.com/2captcha-api#cutcaptcha) + Use this method to solve Cutcaptcha. Returns the response in JSON. ```python result = solver.cutcaptcha(misery_key='ad52c87af17e2ec09b8d918c9f00416b1cb8c320', @@ -300,6 +365,9 @@ result = solver.cutcaptcha(misery_key='ad52c87af17e2ec09b8d918c9f00416b1cb8c320' ``` ### Tencent + +[API method description.](https://2captcha.com/2captcha-api#tencent) + Use this method to solve Cutcaptcha. Returns a token. ```python result = solver.tencent(app_id="197326679", From 4469b214ac3a98ebae3a704a775b80d0093371c6 Mon Sep 17 00:00:00 2001 From: arthur <51604173+arthurauffray@users.noreply.github.com> Date: Tue, 18 Jun 2024 00:46:32 +1200 Subject: [PATCH 4/6] Fix spelling and grammar mistakes in README + more (#89) - Fixed multiple spelling mistakes and grammar issues - Fixed missing/incorrect words - Updated some sentence structures All non-breaking changes. Co-authored-by: Victor --- README.md | 60 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ed959c1..1c75bd9 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,9 @@ The easiest way to quickly integrate the 2Captcha captcha-solving service into y This package can be installed with Pip: -```pip3 install 2captcha-python``` +```bash +pip3 install 2captcha-python +``` ## Configuration @@ -55,7 +57,7 @@ from twocaptcha import TwoCaptcha solver = TwoCaptcha('YOUR_API_KEY') ``` -Also there are a few options that can be configured: +Also, there are a few options that can be configured: ```python config = { @@ -75,37 +77,39 @@ solver = TwoCaptcha(**config) | Option | Default value | Description | | ---------------- | -------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- | | server | `2captcha.com` | API server. You can set it to `rucaptcha.com` if your account is registered there | -| softId | - | your software ID obtained after publishing in [2captcha sofware catalog] | -| callback | - | URL of your web-sever that receives the captcha recognition result. The URl should be first registered in [pingback settings] of your account | -| defaultTimeout | 120 | Polling timeout in seconds for all captcha types except reCAPTCHA. Defines how long the module tries to get the answer from `res.php` API endpoint | -| recaptchaTimeout | 600 | Polling timeout for reCAPTCHA in seconds. Defines how long the module tries to get the answer from `res.php` API endpoint | -| pollingInterval | 10 | Interval in seconds between requests to `res.php` API endpoint, setting values less than 5 seconds is not recommended | +| softId | - | your software ID obtained after publishing in [2captcha software catalog] | +| callback | - | URL of your web server that receives the captcha recognition result. The URL should be first registered in [pingback settings] of your account | +| defaultTimeout | 120 | Polling timeout in seconds for all captcha types except reCAPTCHA. Defines how long the module tries to get the answer from the `res.php` API endpoint | +| recaptchaTimeout | 600 | Polling timeout for reCAPTCHA in seconds. Defines how long the module tries to get the answer from the `res.php` API endpoint | +| pollingInterval | 10 | Interval in seconds between requests to the `res.php` API endpoint. Setting values less than 5 seconds is not recommended | -> **IMPORTANT:** once `callback` is defined for `TwoCaptcha` instance, all methods return only the captcha ID and DO NOT poll the API to get the result. The result will be sent to the callback URL. +> **IMPORTANT:** Once `callback` is defined for the `TwoCaptcha` instance, all methods return only the captcha ID and DO NOT poll the API to get the result. The result will be sent to the callback URL. To get the answer manually use [get_result method](#send--get_result) ## Solve captcha -When you submit any image-based captcha use can provide additional options to help 2captcha workers to solve it properly. +When you submit any image-based CAPTCHA, you can provide additional options to help 2captcha workers solve it properly. ### Captcha options | Option | Default Value | Description | | ------------- | ------------- | -------------------------------------------------------------------------------------------------- | -| numeric | 0 | Defines if captcha contains numeric or other symbols [see more info in the API docs][post options] | -| minLen | 0 | minimal answer lenght | +| numeric | 0 | Defines if the captcha contains numeric or other symbols [see more info in the API docs][post options] | +| minLen | 0 | minimal answer length | | maxLen | 0 | maximum answer length | | phrase | 0 | defines if the answer contains multiple words or not | | caseSensitive | 0 | defines if the answer is case sensitive | | calc | 0 | defines captcha requires calculation | -| lang | - | defines the captcha language, see the [list of supported languages] | -| hintImg | - | an image with hint shown to workers with the captcha | +| lang | - | defines the captcha language; see the [list of supported languages] | +| hintImg | - | an image with a hint shown to workers with the captcha | | hintText | - | hint or task text shown to workers with the captcha | -Below you can find basic examples for every captcha type. Check out [examples directory] to find more examples with all available options. +Below, you can find basic examples for every captcha type. Check out [examples directory] for more examples with all available options. ### Normal Captcha + [API method description.](https://2captcha.com/2captcha-api#solving_normal_captcha) -To bypass a normal captcha (distorted text on an image) use the following method. This method also can be used to recognize any text on the image. +To bypass a normal captcha (distorted text on an image) use the following method. This method can also be used to recognize any text in an image. + ```python result = solver.normal('path/to/captcha.jpg', param1=..., ...) # OR @@ -116,7 +120,7 @@ result = solver.normal('https://site-with-captcha.com/path/to/captcha.jpg', para [API method description.](https://2captcha.com/2captcha-api#audio) -To bypass an audio captcha (mp3 formats only) use the following method. +Use the following method to bypass an audio captcha (mp3 formats only). You must provide the language as `lang = 'en'`. Supported languages are "en", "ru", "de", "el", "pt", "fr". ```python @@ -138,7 +142,8 @@ result = solver.text('If tomorrow is Saturday, what day is today?', param1=..., [API method description.](https://2captcha.com/2captcha-api#solving_recaptchav2_new) -Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection. +Use the following method to solve reCAPTCHA V2 and obtain a token to bypass the protection. + ```python result = solver.recaptcha(sitekey='6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-', url='https://mysite.com/page/with/recaptcha', @@ -298,7 +303,8 @@ result = solver.capy(sitekey='PUZZLE_Abc1dEFghIJKLM2no34P56q7rStu8v', [API method description.](https://2captcha.com/2captcha-api#grid) -Grid method was originally called the Old reCAPTCHA V2 method. The method can be used to bypass any type of captcha where you can apply a grid on an image and click specific grid boxes. Returns numbers of boxes. +The grid method was originally called the Old reCAPTCHA V2 method. The method can be used to bypass any type of captcha where you can apply a grid on an image and click specific grid boxes. Returns numbers of boxes. + ```python result = solver.grid('path/to/captcha.jpg', param1=..., ...) ``` @@ -307,7 +313,8 @@ result = solver.grid('path/to/captcha.jpg', param1=..., ...) [API method description.](https://2captcha.com/2captcha-api#canvas) -Canvas method can be used when you need to draw a line around an object on an image. Returns a set of points' coordinates to draw a polygon. +The canvas method can be used when you need to draw a line around an object on an image. Returns a set of points' coordinates to draw a polygon. + ```python result = solver.canvas('path/to/captcha.jpg', param1=..., ...) ``` @@ -316,7 +323,8 @@ result = solver.canvas('path/to/captcha.jpg', param1=..., ...) [API method description.](https://2captcha.com/2captcha-api#coordinates) -ClickCaptcha method returns coordinates of points on the captcha image. Can be used if you need to click on particular points in the image. +The ClickCaptcha method returns the coordinates of points on the captcha image. It can be used if you need to click on particular points in the image. + ```python result = solver.coordinates('path/to/captcha.jpg', param1=..., ...) ``` @@ -325,7 +333,8 @@ result = solver.coordinates('path/to/captcha.jpg', param1=..., ...) [API method description.](https://2captcha.com/2captcha-api#solving_rotatecaptcha) -This method can be used to solve a captcha that asks to rotate an object. Mostly used to bypass FunCaptcha. Returns the rotation angle. +This method can be used to solve a captcha that asks to rotate an object. It is mostly used to bypass FunCaptcha. Returns the rotation angle. + ```python result = solver.rotate('path/to/captcha.jpg', param1=..., ...) ``` @@ -440,11 +449,12 @@ except TimeoutException as e: ### Proxies -You can pass your proxy as an additional argument for methods: recaptcha, funcaptcha, geetest, geetest v4, hcaptcha, -keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, tencent, amazon waf, mtcaptcha, friendly captcha, cutcaptcha. +You can pass your proxy as an additional argument for the following methods: recaptcha, funcaptcha, geetest, geetest v4, hcaptcha, +keycaptcha, capy puzzle, lemin, atbcaptcha, turnstile, amazon waf, mtcaptcha, friendly captcha, cutcaptcha. + The proxy will be forwarded to the API to solve the captcha. -We have our own proxies that we can offer you. [Buy residential proxies] for avoid restrictions and blocks. [Quick start]. +We have our own proxies that we can offer you. [Buy residential proxies] to avoid restrictions and blocks. [Quick start]. ```python proxy={ @@ -475,7 +485,7 @@ captcha_result = asyncio.run(captchaSolver(image)) ## Examples Examples of solving all supported captcha types are located in the [examples] directory. - +### Useful links [2Captcha]: https://2captcha.com/ [2captcha sofware catalog]: https://2captcha.com/software [pingback settings]: https://2captcha.com/setting/pingback From 61d75a8185b6273d41858aa5dcdaac3532b18523 Mon Sep 17 00:00:00 2001 From: asenatorrr <61660057+asenatorrr@users.noreply.github.com> Date: Tue, 18 Jun 2024 14:28:08 +0300 Subject: [PATCH 5/6] Fix imginstructions key in TwoCaptcha/check_hint_img method (#86) --- twocaptcha/solver.py | 1 + 1 file changed, 1 insertion(+) diff --git a/twocaptcha/solver.py b/twocaptcha/solver.py index e40f0ff..722ec09 100755 --- a/twocaptcha/solver.py +++ b/twocaptcha/solver.py @@ -1028,6 +1028,7 @@ def check_hint_img(self, params): return params, files if not '.' in hint and len(hint) > 50: + params.update({'imginstructions': hint}) return params, files if not os.path.exists(hint): From 78d534b168aab50244a2f1582117d4ba864f9034 Mon Sep 17 00:00:00 2001 From: 2captcha Date: Tue, 18 Jun 2024 08:50:34 -0300 Subject: [PATCH 6/6] v1.2.7 --- twocaptcha/__init__.py | 2 +- twocaptcha/solver.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/twocaptcha/__init__.py b/twocaptcha/__init__.py index 47db6ef..ccac91f 100644 --- a/twocaptcha/__init__.py +++ b/twocaptcha/__init__.py @@ -12,4 +12,4 @@ """ __author__ = '2captcha' -__version__ = '1.2.6' +__version__ = '1.2.7' diff --git a/twocaptcha/solver.py b/twocaptcha/solver.py index 722ec09..f460baf 100755 --- a/twocaptcha/solver.py +++ b/twocaptcha/solver.py @@ -54,7 +54,7 @@ def __init__(self, self.exceptions = SolverExceptions def normal(self, file, **kwargs): - '''Wrapper for solving normal captcha (image). + '''Wrapper for solving a normal captcha (image). Parameters __________