Skip to content

Commit

Permalink
Soft ID Support (2captcha)
Browse files Browse the repository at this point in the history
- Added Soft ID Support for 2captcha
- Updated README
  • Loading branch information
Matthew Lugo committed Nov 11, 2021
1 parent aa05fb7 commit e06b698
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
```

Expand All @@ -36,7 +36,7 @@ captcha_answer = solver.get_token()
| invisible_captcha| false | bool | false | If the captcha is invisible or not.<br />__This param is only required when solving invisible captchas__|
| min_score | false | double |0.7 | Minimum score for v3 captchas.<br />__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.<br />__This param is only required when solving V3 captchas__|

| soft_id | false | int | 4782723 |2captcha Developer ID. <br /> Developers get 10% of spendings of their software users. |

# Supported Sites
- **[Capmonster](https://capmonster.cloud/)**
Expand Down
36 changes: 20 additions & 16 deletions captchatools-go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func main() {
if err != nil {
panic(err)
}
fmt.Println(solver.GetToken())
capToken, err := solver.GetToken()
fmt.Println(capToken)
}

```
Expand All @@ -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.<br />__This param is only required when solving V3 captchas__|
| IsInvisibleCaptcha| false | bool | - | If the captcha is invisible or not.<br />__This param is only required when solving invisible captchas__|
| MinScore | false | float32 | - | Minimum score for v3 captchas.<br />__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.<br />__This param is only required when solving V3 captchas__|
| IsInvisibleCaptcha| false | bool | If the captcha is invisible or not.<br />__This param is only required when solving invisible captchas__|
| MinScore | false | float32 | Minimum score for v3 captchas.<br />__This param is only required when solving V3 and it needs a higher / lower score__|
| SoftID | false | int | 2captcha Developer ID. <br /> Developers get 10% of spendings of their software users. |

<!-- | solving_site| true| String (name of site) or int (site ID) | "capmonster"| Captcha solving site| -->

Expand Down Expand Up @@ -122,7 +125,8 @@ func main() {
panic(err)
}
}
fmt.Println(solver.GetToken())
capToken, err := solver.GetToken()
fmt.Println(capToken)
}

```
Expand Down
3 changes: 3 additions & 0 deletions captchatools-go/twocaptcha.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions captchatools-go/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
}

/*
Expand Down Expand Up @@ -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"`
Expand Down
3 changes: 2 additions & 1 deletion captchatools/harvesters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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":
Expand Down
3 changes: 2 additions & 1 deletion captchatools/twocap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e06b698

Please sign in to comment.