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
12 changes: 7 additions & 5 deletions .rspec_status
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
example_id | status | run_time |
---------------------------------- | ------ | --------------- |
./spec/api_2captcha_spec.rb[1:1] | passed | 0.00937 seconds |
./spec/api_2captcha_spec.rb[1:2:1] | passed | 0.00111 seconds |
./spec/api_2captcha_spec.rb[1:3:1] | passed | 7.1 seconds |
example_id | status | run_time |
---------------------------------- | ------ | --------------------- |
./spec/api_2captcha_spec.rb[1:1] | passed | 0.04326 seconds |
./spec/api_2captcha_spec.rb[1:2:1] | passed | 0.00121 seconds |
./spec/api_2captcha_spec.rb[1:3:1] | passed | 3.15 seconds |
./spec/api_2captcha_spec.rb[1:4:1] | passed | 2 minutes 0.2 seconds |
./spec/api_2captcha_spec.rb[1:5:1] | passed | 0.26142 seconds |
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
ruby-2captcha (0.1.0)
ruby-2captcha (1.0.2)

GEM
remote: https://rubygems.org/
Expand Down
48 changes: 40 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ A Ruby client for the 2Captcha API.
- [Solve captcha](#solve-captcha)
- [Normal Captcha](#normal-captcha)
- [Text](#text-captcha)
- [ReCaptcha v2](#recaptcha-v2)
- [ReCaptcha v3](#recaptcha-v3)
- [reCAPTCHA v2](#recaptcha-v2)
- [reCAPTCHA v3](#recaptcha-v3)
- [reCAPTCHA Enterprise](#recaptcha-enterprise)
- [GeeTest](#geetest)
- [hCaptcha](#hcaptcha)
- [KeyCaptcha](#keycaptcha)
Expand Down Expand Up @@ -71,7 +72,7 @@ client.api_key = "YOUR_API_KEY"
|---|---|---|
|soft_id|-|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|
|default_timeout|120|Timeout in seconds for all captcha types except ReCaptcha. Defines how long the module tries to get the answer from `res.php` API endpoint|
|default_timeout|120|Timeout in seconds for all captcha types except reCAPTCHA. Defines how long the module tries to get the answer from `res.php` API endpoint|
|polling_interval|10|Interval in seconds between requests to `res.php` API endpoint, setting values less than 5 seconds is not recommended|

> **IMPORTANT:** once `callback` is defined for `Client` 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.
Expand Down Expand Up @@ -115,8 +116,8 @@ result = client.text({
})
```

### ReCaptcha v2
Use this method to solve ReCaptcha V2 and obtain a token to bypass the protection.
### reCAPTCHA v2
Use this method to solve reCAPTCHA V2 and obtain a token to bypass the protection.
```ruby
result = client.recaptcha_v2({
googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
Expand All @@ -125,8 +126,8 @@ result = client.recaptcha_v2({
})
```

### ReCaptcha v3
This method provides ReCaptcha V3 solver and returns a token.
### reCAPTCHA v3
This method provides reCAPTCHA V3 solver and returns a token.
```ruby
result = client.recaptcha_v3({
googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
Expand All @@ -135,6 +136,28 @@ result = client.recaptcha_v3({
score: 0.3,
action: 'verify'
})
``

### reCAPTCHA Enterprise
reCAPTCHA Enterprise can be used as reCAPTCHA V2 and reCAPTCHA V3. Below is a usage example for both versions.

```ruby
# reCAPTCHA V2
result = client.recaptcha_v2({
googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
pageurl: 'https://mysite.com/page/with/recaptcha_v2_enterprise',
enterprise: 1
})

# reCAPTCHA V3
result = client.recaptcha_v3({
googlekey: '6Le-wvkSVVABCPBMRTvw0Q4Muexq1bi0DJwx_mJ-',
pageurl: 'https://mysite.com/page/with/recaptcha_v3_enterprise',
version: 'v3',
score: 0.3,
action: 'verify',
enterprise: 1,
})
```

### FunCaptcha
Expand Down Expand Up @@ -190,7 +213,7 @@ result = client.capy({
```

### Grid
Grid method is originally called Old ReCaptcha V2 method. The method can be used to bypass any type of captcha where you can apply a grid on image and need to click specific grid boxes. Returns numbers of boxes.
Grid method is originally called Old reCAPTCHA V2 method. The method can be used to bypass any type of captcha where you can apply a grid on image and need to click specific grid boxes. Returns numbers of boxes.
```ruby
result = client.grid({
image: 'path/to/captcha.jpg',
Expand Down Expand Up @@ -289,6 +312,15 @@ result = client.audio({
})
```

### Yandex
Use this method to solve Yandex and obtain a token to bypass the protection.
```ruby
result = client.yandex({
sitekey: 'Y5Lh0tiycconMJGsFd3EbbuNKSp1yaZESUOIHfeV',
url: "https://rutube.ru"
})
```

## Other methods

### send / get_result
Expand Down
14 changes: 9 additions & 5 deletions lib/api_2captcha/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ def solve(method, params = {}, file_path = nil, return_id: false)
params["key"] = @api_key
params["soft_id"] = @soft_id
params["json"] = 1

if @callback
params["pingback"] = @callback
return_id = true
else
return_id
end

complete_params = get_params(params)
captcha_id = send_request(complete_params)

return_id ? captcha_id : get_result(captcha_id)
return captcha_id if return_id
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не очень понял, что изменилось тут :)

get_result(captcha_id)
end

def send(*args)
Expand Down Expand Up @@ -132,7 +132,7 @@ def capy(params)

def grid(params)
params["recaptcha"] = 1
solve("capy", params)
solve("post", params)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему тут post?

end

def canvas(params)
Expand Down Expand Up @@ -178,6 +178,10 @@ def audio(params)
solve("audio", params)
end

def yandex(params)
solve("yandex", params)
end

private

def base_url
Expand Down