From e06b6989b3f7b3e8439efbb046d342db6d2f92a3 Mon Sep 17 00:00:00 2001 From: Matthew Lugo Date: Wed, 10 Nov 2021 21:28:35 -0500 Subject: [PATCH] Soft ID Support (2captcha) - Added Soft ID Support for 2captcha - Updated README --- README.md | 6 +++--- captchatools-go/README.md | 36 +++++++++++++++++++---------------- captchatools-go/twocaptcha.go | 3 +++ captchatools-go/types.go | 2 ++ captchatools/harvesters.py | 3 ++- captchatools/twocap.py | 3 ++- 6 files changed, 32 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 35a9ed7..633483e 100644 --- a/README.md +++ b/README.md @@ -16,13 +16,13 @@ pip3 install -U captchatools # How to use ```python import captchatools -solver = captchatools.captcha_harvesters(solving_site="capmonster", api_key="YOUR API KEY", sitekey="SITEKEY", captcha_url="https://www.google.com/recaptcha/api2/demo") +solver = captchatools.captcha_harvesters(solving_site="capmonster", api_key="YOUR API KEY", sitekey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", captcha_url="https://www.google.com/recaptcha/api2/demo") captcha_answer = solver.get_token() ``` or ```python from captchatools import captcha_harvesters, exceptions -solver = captcha_harvesters(solving_site=1, api_key="YOUR API KEY", sitekey="SITEKEY", captcha_url="https://www.google.com/recaptcha/api2/demo") +solver = captcha_harvesters(solving_site=1, api_key="YOUR API KEY", sitekey="6Le-wvkSAAAAAPBMRTvw0Q4Muexq9bi0DJwx_mJ-", captcha_url="https://www.google.com/recaptcha/api2/demo") captcha_answer = solver.get_token() ``` @@ -36,7 +36,7 @@ captcha_answer = solver.get_token() | invisible_captcha| false | bool | false | If the captcha is invisible or not.
__This param is only required when solving invisible captchas__| | min_score | false | double |0.7 | Minimum score for v3 captchas.
__This param is only required when solving V3 and it needs a higher / lower score__| | action | false | String | "verify" | Action that is associated with the V3 captcha.
__This param is only required when solving V3 captchas__| - +| soft_id | false | int | 4782723 |2captcha Developer ID.
Developers get 10% of spendings of their software users. | # Supported Sites - **[Capmonster](https://capmonster.cloud/)** diff --git a/captchatools-go/README.md b/captchatools-go/README.md index cebc5e3..51db36a 100644 --- a/captchatools-go/README.md +++ b/captchatools-go/README.md @@ -30,7 +30,8 @@ func main() { if err != nil { panic(err) } - fmt.Println(solver.GetToken()) + capToken, err := solver.GetToken() + fmt.Println(capToken) } ``` @@ -48,27 +49,29 @@ func v3Example() { if err != nil { panic(err) } - fmt.Println(solver.GetToken()) + capToken, err := solver.GetToken() + fmt.Println(capToken) } ``` ### captchatools.NewHarvester() Parameters: -| Parameter | Required | Type | Default | Description| -| :-------------: |:-------------:| :-----:| :-----:| :-----:| -| solving_site | true | int| -| The captcha solving site that will be used. Refer to [the site IDs](https://github.com/Matthew17-21/Captcha-Tools/tree/main/captchatools-go#site-specific-support). Alternatively, you can use shortcuts such as `captchatools.AnticaptchaSite` | -| Config| true | captchatools.Config | - | Configurations for the captchas you are solving. | +| Parameter | Required | Type | Description| +| :-------------: |:-------------:| :-----:| :-----:| +| solving_site | true | int| The captcha solving site that will be used. Refer to [the site IDs](https://github.com/Matthew17-21/Captcha-Tools/tree/main/captchatools-go#site-specific-support). Alternatively, you can use shortcuts such as `captchatools.AnticaptchaSite` | +| Config| true | captchatools.Config | Configurations for the captchas you are solving. | ### Config struct fields: -| Field | Required | Type | Default | Description| -| :-------------: |:-------------:| :-----:| :-----:| :-----:| -| Api_key | true | String| -| The API Key for the captcha solving site| -| Sitekey| true | String | - | Sitekey from the site where captcha is loaded| -| CaptchaURL | true| String | - | URL where the captcha is located| -| CaptchaType| true| String | - | Type of captcha you are solving. Either captcha `v2`, `v3` or `hcaptcha` (`hcap` works aswell)| -| Action | false | String | - | Action that is associated with the V3 captcha.
__This param is only required when solving V3 captchas__| -| IsInvisibleCaptcha| false | bool | - | If the captcha is invisible or not.
__This param is only required when solving invisible captchas__| -| MinScore | false | float32 | - | Minimum score for v3 captchas.
__This param is only required when solving V3 and it needs a higher / lower score__| +| Field | Required | Type | Description| +| :-------------: |:-------------:| :-----:| :-----:| +| Api_key | true | String| The API Key for the captcha solving site| +| Sitekey| true | String | Sitekey from the site where captcha is loaded| +| CaptchaURL | true| String | URL where the captcha is located| +| CaptchaType| true| String | Type of captcha you are solving. Either captcha `v2`, `v3` or `hcaptcha` (`hcap` works aswell)| +| Action | false | String | Action that is associated with the V3 captcha.
__This param is only required when solving V3 captchas__| +| IsInvisibleCaptcha| false | bool | If the captcha is invisible or not.
__This param is only required when solving invisible captchas__| +| MinScore | false | float32 | Minimum score for v3 captchas.
__This param is only required when solving V3 and it needs a higher / lower score__| +| SoftID | false | int | 2captcha Developer ID.
Developers get 10% of spendings of their software users. | @@ -122,7 +125,8 @@ func main() { panic(err) } } - fmt.Println(solver.GetToken()) + capToken, err := solver.GetToken() + fmt.Println(capToken) } ``` diff --git a/captchatools-go/twocaptcha.go b/captchatools-go/twocaptcha.go index fa46634..0b3890e 100644 --- a/captchatools-go/twocaptcha.go +++ b/captchatools-go/twocaptcha.go @@ -99,6 +99,9 @@ func (t *Twocaptcha) createPayload() (string, error) { } // Add any other keys to the payload + if t.config.SoftID != 0 { + payload.SoftID = t.config.SoftID + } switch t.config.CaptchaType { case "v2": payload.Googlekey = t.config.Sitekey diff --git a/captchatools-go/types.go b/captchatools-go/types.go index ddf4ddd..0f89139 100644 --- a/captchatools-go/types.go +++ b/captchatools-go/types.go @@ -28,6 +28,7 @@ type ( Action string // Action that is associated with the V3 captcha. IsInvisibleCaptcha bool // If the captcha is invisible or not. MinScore float32 // Minimum score for v3 captchas. + SoftID int // SoftID for 2captcha. Developers get reward 10% of spendings of their software users. } /* @@ -111,6 +112,7 @@ type ( Version string `json:"version,omitempty"` Action string `json:"action,omitempty"` MinScore float32 `json:"min_score,omitempty"` + SoftID int `json:"soft_id,omitempty"` } twocaptchaResponse struct { Status int `json:"status"` diff --git a/captchatools/harvesters.py b/captchatools/harvesters.py index 2aedb42..4ff7655 100644 --- a/captchatools/harvesters.py +++ b/captchatools/harvesters.py @@ -9,7 +9,7 @@ def __init__( self, solving_site=1, captcha_type="v2", invisible_captcha=False, sitekey="Sitekey of the page where the captcha is loaded", captcha_url="The site URL of where the captcha is loaded", - action="verify", min_score=0.7): + action="verify", min_score=0.7, soft_id=4782723): self.api_key = api_key self.solving_site = solving_site self.captcha_type = captcha_type.lower() @@ -18,6 +18,7 @@ def __init__( self, solving_site=1, self.min_score = min_score self.sitekey = sitekey self.action = action + self.soft_id = soft_id # Get Token from Capmonster API if self.solving_site == 1 or str(self.solving_site).lower() == "capmonster": diff --git a/captchatools/twocap.py b/captchatools/twocap.py index c49e687..a82881a 100644 --- a/captchatools/twocap.py +++ b/captchatools/twocap.py @@ -24,7 +24,8 @@ def get_id(self) -> int: "pageurl":self.user_data.captcha_url, "json": 1 } - + if self.user_data.soft_id is not None: + payload["soft_id"] = self.user_data.soft_id if self.user_data.captcha_type == "v2": if self.user_data.invisible_captcha: payload["invisible"] = 1