two_captcha 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +34 -9
- data/lib/two_captcha/client.rb +55 -0
- data/lib/two_captcha/errors.rb +8 -1
- data/lib/two_captcha/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29bc40bcdecf08c3315a97224e2dbc0b7308f737
|
4
|
+
data.tar.gz: f16d6172e691101d63534746c83da27d109abdb0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36c9c2bd793aba1dda0b4ce7414ab2b56ae5193c314714f6b2b33f22cec13ecc8ffbf29ac0fb997b866890079b3131b316a26c5a05274bc300e55d93072f6573
|
7
|
+
data.tar.gz: 0d7d9a545bdfa066e551031a824129635ca4b4f2639de54204bb2d7d2beeb8a9fc40b93e51bc1eba051836534b68ead71a595dff9be271300b1b6aa327710de3
|
data/README.md
CHANGED
@@ -98,9 +98,34 @@ Or install it yourself as:
|
|
98
98
|
|
99
99
|
## Clickable CAPTCHAs (e.g. "No CAPTCHA reCAPTCHA")
|
100
100
|
|
101
|
-
|
102
|
-
[reCAPTCHA v2](https://support.google.com/recaptcha/?hl=en#6262736)
|
103
|
-
|
101
|
+
There are two ways of solving captchas similar to
|
102
|
+
[reCAPTCHA v2](https://support.google.com/recaptcha/?hl=en#6262736).
|
103
|
+
|
104
|
+
### (Prefered) Sending the `googlekey` and `pageurl` parameters
|
105
|
+
|
106
|
+
This method requires no browser emulation. You can send two parameters that identify website in which the captcha is found.
|
107
|
+
|
108
|
+
Please read the oficial documentation at https://2captcha.com/newapi-recaptcha-en for
|
109
|
+
more information.
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
options = {
|
113
|
+
googlekey: 'xyz',
|
114
|
+
pageurl: 'http://example.com/example=1'
|
115
|
+
}
|
116
|
+
|
117
|
+
client.decode_recaptcha_v2(options)
|
118
|
+
```
|
119
|
+
|
120
|
+
The response will be a code that validates the form, like the following:
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
"03AHJ_VuuHAqJKxcTH6sbTsqw-L1Sm4gD57PTeaEr9-MaETG1vfu2H5zlcw0u2KqgjHPiXWwlulOw0Ef82tH6SOSbXdelgkvdDl8HreKFug05zfadw2n-A2HoTgYteVA53Q46VatEcZofa5eKfaWgvrPS-IP1DpV4bnUEG69-VbWAx7fJ-p4rHSxq-ZYesBkk9yYFrAiT_70uSz8lg3iqRImfRW91RIkEq8A5UBn4vABUQvlDV4eoKpeNUKDmHOABHkdsV8_1KEgCbabIwsIuIkN1_hw-Mkg0NRdWuXgNtOWen0Zv65yl6D31yhyLV2s0h3ygQwrpxJpBWs7o_rG2TaVfi0y9S5cYr-YlMTHszvMQCVllf5WAiNAgV28JuAnFH5WqRHqT56Tz6ZVNigIToEzq1tnfuewgmJuyyP_woy_MGRoZoHxx6V9yUDw8Ig-hYD8kakmSnnjNQd50w_Y_tI3aDLp-s_7ZmhH6pcaoWWsid5hdtMXyvrP9DscDuCLBf7etLle8caPWSaYCpAq9DOTtj5NpSg6-OeCJdGdgIPT9Xdbo_dm4pLGZ0CNd5WQcjil_kZN_uErRssv9r8j5SC6tsIPBneQLqqqsg8Hyt9kjIh0N10d6-sFeV3QWw-OuzCrPSNYc-_AxvwaB0GUAOmHDDbj8kKz1oqfdBwJienRm246cbstqdc7uAHHuLWLpt1A5W-56PEbb3Zs-HNo3kcjvlJcfrOVJKW68-G3S635EJ9SBm9GFKzFojEu4-TF9CvYNJKaXY9dDev_TVbBaWpWN2Ctx5hHKRbtD1_g2LsGUTDkpo7wrf4pbAyP34zeMRBI1wrrV12PBKnuafaMjy2KIFLt0LM91uWiBzEC61AiSKKEwP2nydRIyIFGwbLFUMeGeqmje87wSajcjmdjl_w4XZBY2zy8fUH6XoAGZ6AeCTulIljBQDObQynKDd-rutPvKNxZw3sra3yRt9ziDVKKDk-LbhTfw508g1lu9io6jnvm3kbAdnkfZ0x0PkGiUMHU7hnuoW6bXo2Yn_Zt5tDWL7N7wFtY6B0k7cTy73f8er508zReOuoyz2NqL8smDCmcJu05kr5R6OVHfeUszn5OiYeVh8Q_gTMsEf4wdaOsQWGZhWQIS8Vi_6IYzwQsnOtYdI6T8q4IDrQh-9eemVn0gNI6gdyknStQ7DoujdPGt20qzpURMwHaw"
|
124
|
+
```
|
125
|
+
|
126
|
+
### Sending the challenge image
|
127
|
+
|
128
|
+
You can add the param `coordinatescaptcha: 1` to your request.
|
104
129
|
|
105
130
|
Please read the oficial documentation at https://2captcha.com/en-api-recaptcha for
|
106
131
|
more information.
|
@@ -118,6 +143,11 @@ more information.
|
|
118
143
|
The response will be an array containing coordinates where the captcha should be
|
119
144
|
clicked. For the captcha above it should look something like:
|
120
145
|
|
146
|
+
```ruby
|
147
|
+
# captcha.text
|
148
|
+
"coordinates:x=50.66999816894531,y=130.3300018310547;x=236.66998291015625,y=328.3299865722656"
|
149
|
+
```
|
150
|
+
|
121
151
|
## Audio reCAPTCHA v2
|
122
152
|
|
123
153
|
```ruby
|
@@ -157,18 +187,13 @@ convertions before calling the API.
|
|
157
187
|
|
158
188
|
TwoCaptcha gem uses [Semantic Versioning](http://semver.org/).
|
159
189
|
|
160
|
-
#### Ruby versions
|
190
|
+
#### Tested Ruby versions
|
161
191
|
|
162
192
|
* MRI 2.2.2
|
163
193
|
* MRI 2.2.0
|
164
194
|
* MRI 2.1.4
|
165
195
|
* MRI 2.0.0
|
166
196
|
|
167
|
-
# Maintainers
|
168
|
-
|
169
|
-
* [Marcelo Mita](http://github.com/marcelomita)
|
170
|
-
* [Rafael Barbolo](http://github.com/barbolo)
|
171
|
-
|
172
197
|
## Contributing
|
173
198
|
|
174
199
|
1. Fork it ( https://github.com/infosimples/two_captcha/fork )
|
data/lib/two_captcha/client.rb
CHANGED
@@ -78,6 +78,61 @@ module TwoCaptcha
|
|
78
78
|
decoded_captcha
|
79
79
|
end
|
80
80
|
|
81
|
+
#
|
82
|
+
# Solve reCAPTCHA v2.
|
83
|
+
#
|
84
|
+
# @param [Hash] options Options hash. Check docs for the method decode!.
|
85
|
+
#
|
86
|
+
# @return [TwoCaptcha::Captcha] The solution of the given captcha.
|
87
|
+
#
|
88
|
+
def decode_recaptcha_v2(options = {})
|
89
|
+
decode_recaptcha_v2!(options)
|
90
|
+
rescue TwoCaptcha::Error => ex
|
91
|
+
TwoCaptcha::Captcha.new
|
92
|
+
end
|
93
|
+
|
94
|
+
#
|
95
|
+
# Solve reCAPTCHA v2.
|
96
|
+
#
|
97
|
+
# @param [Hash] options Options hash.
|
98
|
+
# @option options [String] :googlekey The open key of the site in which recaptcha is installed.
|
99
|
+
# @option options [String] :pageurl The URL of the page where the recaptcha is encountered.
|
100
|
+
#
|
101
|
+
# @return [TwoCaptcha::Captcha] The solution of the given captcha.
|
102
|
+
#
|
103
|
+
def decode_recaptcha_v2!(options = {})
|
104
|
+
started_at = Time.now
|
105
|
+
|
106
|
+
fail(TwoCaptcha::GoogleKey) if options[:googlekey].empty?
|
107
|
+
|
108
|
+
payload_in = {
|
109
|
+
method: 'userrecaptcha',
|
110
|
+
googlekey: options[:googlekey],
|
111
|
+
pageurl: options[:pageurl]
|
112
|
+
}
|
113
|
+
|
114
|
+
response_in = request('in', :get, payload_in)
|
115
|
+
status, captcha_id = response_in.split('|')
|
116
|
+
|
117
|
+
payload_res = {
|
118
|
+
action: 'get',
|
119
|
+
json: '1',
|
120
|
+
id: captcha_id
|
121
|
+
}
|
122
|
+
|
123
|
+
response_res = request('res', :get, payload_res)
|
124
|
+
result = JSON.load(response_res)
|
125
|
+
|
126
|
+
while ['CAPCHA_NOT_READY', 'CAPTCHA_NOT_READY'].include? result['request']
|
127
|
+
sleep(polling)
|
128
|
+
response_res = request('res', :get, payload_res)
|
129
|
+
result = JSON.load(response_res)
|
130
|
+
fail TwoCaptcha::Timeout if (Time.now - started_at) > timeout
|
131
|
+
end
|
132
|
+
|
133
|
+
result['request']
|
134
|
+
end
|
135
|
+
|
81
136
|
# Upload a captcha to 2Captcha.
|
82
137
|
#
|
83
138
|
# This method will not return the solution. It helps on separating concerns.
|
data/lib/two_captcha/errors.rb
CHANGED
@@ -98,6 +98,12 @@ module TwoCaptcha
|
|
98
98
|
end
|
99
99
|
end
|
100
100
|
|
101
|
+
class GoogleKey < Error
|
102
|
+
def initialize
|
103
|
+
super('Missing googlekey parameter')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
101
107
|
RESPONSE_ERRORS = {
|
102
108
|
'ERROR_WRONG_USER_KEY' => TwoCaptcha::WrongUserKey,
|
103
109
|
'ERROR_KEY_DOES_NOT_EXIST' => TwoCaptcha::InvalidUserKey,
|
@@ -111,6 +117,7 @@ module TwoCaptcha
|
|
111
117
|
'IP_BANNED' => TwoCaptcha::IpBanned,
|
112
118
|
'ERROR_WRONG_ID_FORMAT' => TwoCaptcha::WrongIdFormat,
|
113
119
|
'ERROR_CAPTCHA_UNSOLVABLE' => TwoCaptcha::CaptchaUnsolvable,
|
114
|
-
'ERROR_EMPTY_ACTION' => TwoCaptcha::EmptyAction
|
120
|
+
'ERROR_EMPTY_ACTION' => TwoCaptcha::EmptyAction,
|
121
|
+
'ERROR_GOOGLEKEY' => TwoCaptcha::GoogleKey
|
115
122
|
}
|
116
123
|
end
|
data/lib/two_captcha/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: two_captcha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Mita
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-01-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.5.1
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Ruby API for 2Captcha (Captcha Solver as a Service)
|