two_captcha 1.4.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +38 -4
- data/lib/two_captcha/client.rb +52 -2
- data/lib/two_captcha/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ea861217de7f6655a791908c0a8e8935b36d22fce3eb916e16ac0a8c7ccccef7
|
4
|
+
data.tar.gz: 9e87f7308dd3127a986a9204abd8a640033f19b0f0d87df53edd5e932bfaad90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f00da9ab5ba1fc674aeb5af1b2423a0ec345ca7ceeac33368a5254277807bf406363aea59350c11938be5f7336154d275b06141b5b58592b004bfaf83817c5f
|
7
|
+
data.tar.gz: c3b9134f597e250de37caf4d6ec24afe70f6a6a507f7f578e24686d934db2ddcc4551c5f137eeb64c3c3bb33a1fa41dcbc00804e5430554d31ab70b081216ff2
|
data/README.md
CHANGED
@@ -66,10 +66,13 @@ Or install it yourself as:
|
|
66
66
|
captcha = client.captcha('130920620') # with 130920620 as the captcha id
|
67
67
|
```
|
68
68
|
|
69
|
-
4. **Report incorrectly
|
69
|
+
4. **Report incorrectly (for refund) or correctly (useful for reCAPTCHA v3) solved captcha**
|
70
70
|
|
71
71
|
```ruby
|
72
|
-
client.report!('130920620') # with 130920620 as the captcha id
|
72
|
+
client.report!('130920620', 'reportbad') # with 130920620 as the captcha id
|
73
|
+
# return true if successfully reported
|
74
|
+
|
75
|
+
client.report!('256892751', 'reportgood') # with 256892751 as the captcha id
|
73
76
|
# return true if successfully reported
|
74
77
|
```
|
75
78
|
|
@@ -96,7 +99,7 @@ Or install it yourself as:
|
|
96
99
|
# return an XML string with the current service load.
|
97
100
|
```
|
98
101
|
|
99
|
-
##
|
102
|
+
## reCAPTCHA v2 (e.g. "No CAPTCHA reCAPTCHA")
|
100
103
|
|
101
104
|
There are two ways of solving captchas similar to
|
102
105
|
[reCAPTCHA v2](https://support.google.com/recaptcha/?hl=en#6262736).
|
@@ -115,7 +118,7 @@ for more information.
|
|
115
118
|
pageurl: 'http://example.com/example=1'
|
116
119
|
}
|
117
120
|
|
118
|
-
client.decode_recaptcha_v2(options)
|
121
|
+
captcha = client.decode_recaptcha_v2(options)
|
119
122
|
captcha.text # Solution of the captcha
|
120
123
|
captcha.id # Numeric ID of the captcha solved by TwoCaptcha
|
121
124
|
```
|
@@ -165,6 +168,37 @@ The response will be a simple text:
|
|
165
168
|
'61267'
|
166
169
|
```
|
167
170
|
|
171
|
+
## reCAPTCHA v3
|
172
|
+
|
173
|
+
This method requires no browser emulation. You can send four parameters that
|
174
|
+
identify the website in which the CAPTCHA is found and the minimum score
|
175
|
+
(0.3, 0.5 or 0.7) you desire.
|
176
|
+
|
177
|
+
**It's strongly recommended to use a minimum score of 0.3 as higher scores are extremely rare.**
|
178
|
+
|
179
|
+
Please read the [oficial documentation](https://2captcha.com/2captcha-api#solving_recaptchav3)
|
180
|
+
for more information.
|
181
|
+
|
182
|
+
```ruby
|
183
|
+
options = {
|
184
|
+
googlekey: 'xyz',
|
185
|
+
pageurl: 'http://example.com/example=1',
|
186
|
+
action: 'verify',
|
187
|
+
min_score: 0.3
|
188
|
+
}
|
189
|
+
|
190
|
+
captcha = client.decode_recaptcha_v3(options)
|
191
|
+
captcha.text # Solution of the captcha
|
192
|
+
captcha.id # Numeric ID of the captcha solved by TwoCaptcha
|
193
|
+
```
|
194
|
+
|
195
|
+
The solution (`captcha.text`) will be a code that validates the form, like the
|
196
|
+
following:
|
197
|
+
|
198
|
+
```ruby
|
199
|
+
"1JJHJ_VuuHAqJKxcaasbTsqw-L1Sm4gD57PTeaEr9-MaETG1vfu2H5zlcwkjsRoZoHxx6V9yUDw8Ig-hYD8kakmSnnjNQd50w_Y_tI3aDLp-s_7ZmhH6pcaoWWsid5hdtMXyvrP9DscDuCLBf7etLle8caPWSaYCpAq9DOTtj5NpSg6-OeCJdGdkjsakFUMeGeqmje87wSajcjmdjl_w4XZBY2zy8fUH6XoAGZ6AeCTulIljBQDObQynKDd-rutPvKNxZasDk-LbhTfw508g1lu9io6jnvm3kbAdnkfZ0x0PkGiUMHU7hnuoW6bXo2Yn_Zt5tDWL7N7wFtY6B0k7cTy73f8er508zReOuoyz2NqL8smDCmcJu05ajkPGt20qzpURMwHaw"
|
200
|
+
```
|
201
|
+
|
168
202
|
## Notes
|
169
203
|
|
170
204
|
#### Thread-safety
|
data/lib/two_captcha/client.rb
CHANGED
@@ -122,6 +122,55 @@ module TwoCaptcha
|
|
122
122
|
decoded_captcha
|
123
123
|
end
|
124
124
|
|
125
|
+
#
|
126
|
+
# Solve reCAPTCHA v3.
|
127
|
+
#
|
128
|
+
# @param [Hash] options Options hash. Check docs for the method decode!.
|
129
|
+
#
|
130
|
+
# @return [TwoCaptcha::Captcha] The solution of the given captcha.
|
131
|
+
#
|
132
|
+
def decode_recaptcha_v3(options = {})
|
133
|
+
decode_recaptcha_v3!(options)
|
134
|
+
rescue TwoCaptcha::Error => ex
|
135
|
+
TwoCaptcha::Captcha.new
|
136
|
+
end
|
137
|
+
|
138
|
+
#
|
139
|
+
# Solve reCAPTCHA v3.
|
140
|
+
#
|
141
|
+
# @param [Hash] options Options hash.
|
142
|
+
# @option options [String] :googlekey The open key of the site in which recaptcha is installed.
|
143
|
+
# @option options [String] :pageurl The URL of the page where the recaptcha is encountered.
|
144
|
+
# @option options [String] :action The action paramenter present on the page that uses recaptcha.
|
145
|
+
# @option options [String] :min_score The minimum score necessary to pass the challenge.
|
146
|
+
#
|
147
|
+
# @return [TwoCaptcha::Captcha] The solution of the given captcha.
|
148
|
+
#
|
149
|
+
def decode_recaptcha_v3!(options = {})
|
150
|
+
started_at = Time.now
|
151
|
+
|
152
|
+
fail(TwoCaptcha::GoogleKey) if options[:googlekey].empty?
|
153
|
+
|
154
|
+
upload_options = {
|
155
|
+
method: 'userrecaptcha',
|
156
|
+
version: 'v3',
|
157
|
+
googlekey: options[:googlekey],
|
158
|
+
pageurl: options[:pageurl],
|
159
|
+
action: options[:action],
|
160
|
+
min_score: options[:min_score]
|
161
|
+
}
|
162
|
+
decoded_captcha = upload(upload_options)
|
163
|
+
|
164
|
+
# pool untill the answer is ready
|
165
|
+
while decoded_captcha.text.to_s.empty?
|
166
|
+
sleep([polling, 10].max) # sleep at least 10 seconds
|
167
|
+
decoded_captcha = captcha(decoded_captcha.id)
|
168
|
+
fail TwoCaptcha::Timeout if (Time.now - started_at) > timeout
|
169
|
+
end
|
170
|
+
|
171
|
+
decoded_captcha
|
172
|
+
end
|
173
|
+
|
125
174
|
# Upload a captcha to 2Captcha.
|
126
175
|
#
|
127
176
|
# This method will not return the solution. It helps on separating concerns.
|
@@ -167,11 +216,12 @@ module TwoCaptcha
|
|
167
216
|
# Report incorrectly solved captcha for refund.
|
168
217
|
#
|
169
218
|
# @param [Integer] id Numeric ID of the captcha.
|
219
|
+
# @param [Integer] action 'reportbad' (default) or 'reportgood'.
|
170
220
|
#
|
171
221
|
# @return [Boolean] true if correctly reported
|
172
222
|
#
|
173
|
-
def report!(captcha_id)
|
174
|
-
response = request('res', :get, action:
|
223
|
+
def report!(captcha_id, action = 'reportbad')
|
224
|
+
response = request('res', :get, action: action, id: captcha_id)
|
175
225
|
response == 'OK_REPORT_RECORDED'
|
176
226
|
end
|
177
227
|
|
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.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Barbolo
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-07-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -103,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
103
103
|
- !ruby/object:Gem::Version
|
104
104
|
version: '0'
|
105
105
|
requirements: []
|
106
|
-
|
107
|
-
rubygems_version: 2.4.3
|
106
|
+
rubygems_version: 3.0.3
|
108
107
|
signing_key:
|
109
108
|
specification_version: 4
|
110
109
|
summary: Ruby API for 2Captcha (Captcha Solver as a Service)
|