anti_captcha 2.2.2 → 2.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 -4
- data/lib/anti_captcha.rb +1 -0
- data/lib/anti_captcha/client.rb +52 -4
- data/lib/anti_captcha/models/h_captcha_solution.rb +13 -0
- data/lib/anti_captcha/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 714b5c0e2058c2056e0b0a0fcdf41c0c07147f29b690bbf49132cc7ffbca976e
|
|
4
|
+
data.tar.gz: 3c7942ec7d1a4a747a53fa690be368466e84ce0e9baefe9877a6fb33a4d034bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: db68e12ba53274a19e85a0babc1236a640b59c844b5e87781afdda0f3648e98fb3c64e37047f21a4a7443e5a6d5533347b5d9aad9de172651d782568b22abd52
|
|
7
|
+
data.tar.gz: 8001df4b7668af35346bc00fcde615f369b5ae38b87b31f59704ff60c68028d4113c553b7c90258801cf3c7a3dfd358b6fc5c1f220d66fada7f1f9c31374f529
|
data/README.md
CHANGED
|
@@ -74,10 +74,17 @@ Or install it yourself as:
|
|
|
74
74
|
5. **Get current stats of a queue.**
|
|
75
75
|
|
|
76
76
|
Queue IDs:
|
|
77
|
-
- `1`
|
|
78
|
-
- `2`
|
|
79
|
-
- `5`
|
|
80
|
-
- `6`
|
|
77
|
+
- `1` Standart ImageToText, English language.
|
|
78
|
+
- `2` Standart ImageToText, Russian language.
|
|
79
|
+
- `5` Recaptcha NoCaptcha tasks.
|
|
80
|
+
- `6` Recaptcha Proxyless task.
|
|
81
|
+
- `7` Funcaptcha task.
|
|
82
|
+
- `10` Funcaptcha Proxyless task.
|
|
83
|
+
- `18` Recaptcha V3 s0.3
|
|
84
|
+
- `19` Recaptcha V3 s0.7
|
|
85
|
+
- `20` Recaptcha V3 s0.9
|
|
86
|
+
- `21` hCaptcha Proxy-On
|
|
87
|
+
- `22` hCaptcha Proxyless
|
|
81
88
|
|
|
82
89
|
```ruby
|
|
83
90
|
client.get_queue_stats!(queue_id)
|
|
@@ -171,6 +178,29 @@ Or install it yourself as:
|
|
|
171
178
|
"1JJHJ_VuuHAqJKxcaasbTsqw-L1Sm4gD57PTeaEr9-MaETG1vfu2H5zlcwkjsRoZoHxx6V9yUDw8Ig-hYD8kakmSnnjNQd50w_Y_tI3aDLp-s_7ZmhH6pcaoWWsid5hdtMXyvrP9DscDuCLBf7etLle8caPWSaYCpAq9DOTtj5NpSg6-OeCJdGdkjsakFUMeGeqmje87wSajcjmdjl_w4XZBY2zy8fUH6XoAGZ6AeCTulIljBQDObQynKDd-rutPvKNxZasDk-LbhTfw508g1lu9io6jnvm3kbAdnkfZ0x0PkGiUMHU7hnuoW6bXo2Yn_Zt5tDWL7N7wFtY6B0k7cTy73f8er508zReOuoyz2NqL8smDCmcJu05ajkPGt20qzpURMwHaw"
|
|
172
179
|
```
|
|
173
180
|
|
|
181
|
+
9. **hCaptcha**
|
|
182
|
+
|
|
183
|
+
This method allows you to solve hCaptcha.
|
|
184
|
+
|
|
185
|
+
There are two methods available:
|
|
186
|
+
|
|
187
|
+
- `decode_h_captcha`: solves hCaptcha CAPTCHAs. It doesn't raise exceptions.
|
|
188
|
+
- `decode_h_captcha!`: solves hCaptcha CAPTCHAs. It may raise an error if something goes wrong.
|
|
189
|
+
|
|
190
|
+
**Send the `website_key` and `website_url` parameters**
|
|
191
|
+
|
|
192
|
+
This method requires no browser emulation. You can send two parameters that
|
|
193
|
+
identify the website in which the CAPTCHA is found.
|
|
194
|
+
|
|
195
|
+
```ruby
|
|
196
|
+
options = {
|
|
197
|
+
website_key: 'xyz',
|
|
198
|
+
website_url: 'http://example.com/example=1'
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
solution = client.decode_h_captcha!(options)
|
|
202
|
+
solution.g_recaptcha_response # Solution of the captcha
|
|
203
|
+
```
|
|
174
204
|
|
|
175
205
|
## Notes
|
|
176
206
|
|
data/lib/anti_captcha.rb
CHANGED
|
@@ -36,6 +36,7 @@ require 'anti_captcha/models/image_to_text_solution'
|
|
|
36
36
|
require 'anti_captcha/models/no_captcha_solution'
|
|
37
37
|
require 'anti_captcha/models/recaptcha_v3_solution'
|
|
38
38
|
require 'anti_captcha/models/fun_captcha_solution'
|
|
39
|
+
require 'anti_captcha/models/h_captcha_solution'
|
|
39
40
|
require 'anti_captcha/models/task_result'
|
|
40
41
|
require 'anti_captcha/client'
|
|
41
42
|
require 'anti_captcha/version'
|
data/lib/anti_captcha/client.rb
CHANGED
|
@@ -4,8 +4,8 @@ module AntiCaptcha
|
|
|
4
4
|
#
|
|
5
5
|
class Client
|
|
6
6
|
BASE_URL = 'https://api.anti-captcha.com/:action'
|
|
7
|
-
PROXYABLE_TASKS = %w(NoCaptchaTask FunCaptchaTask)
|
|
8
|
-
SUPPORTED_TASKS = %w(ImageToTextTask NoCaptchaTask FunCaptchaTask)
|
|
7
|
+
PROXYABLE_TASKS = %w(NoCaptchaTask FunCaptchaTask HCaptchaTask)
|
|
8
|
+
SUPPORTED_TASKS = %w(ImageToTextTask NoCaptchaTask FunCaptchaTask HCaptchaTask)
|
|
9
9
|
|
|
10
10
|
attr_accessor :client_key, :timeout, :polling
|
|
11
11
|
|
|
@@ -167,6 +167,42 @@ module AntiCaptcha
|
|
|
167
167
|
AntiCaptcha::FunCaptchaSolution.new(task_result)
|
|
168
168
|
end
|
|
169
169
|
|
|
170
|
+
#
|
|
171
|
+
# Decodes a HCaptcha CAPTCHA.
|
|
172
|
+
#
|
|
173
|
+
# @see `AntiCaptcha::Client#decode_h_captcha!`
|
|
174
|
+
#
|
|
175
|
+
def decode_h_captcha(options, proxy = nil)
|
|
176
|
+
decode_h_captcha!(options, proxy)
|
|
177
|
+
rescue
|
|
178
|
+
AntiCaptcha::HCaptchaSolution.new
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
#
|
|
182
|
+
# Decodes a HCaptcha CAPTCHA.
|
|
183
|
+
#
|
|
184
|
+
# @param [Hash] options Options hash.
|
|
185
|
+
# @option options [String] :website_url
|
|
186
|
+
# @option options [String] :website_key
|
|
187
|
+
#
|
|
188
|
+
# @param [Hash] proxy Not mandatory. A hash with configs of the proxy that
|
|
189
|
+
# has to be used. Defaults to `nil`.
|
|
190
|
+
# @option proxy [String] :proxy_type
|
|
191
|
+
# @option proxy [String] :proxy_address
|
|
192
|
+
# @option proxy [String] :proxy_port
|
|
193
|
+
# @option proxy [String] :proxy_login
|
|
194
|
+
# @option proxy [String] :proxy_login
|
|
195
|
+
# @option proxy [String] :proxy_password
|
|
196
|
+
# @option proxy [String] :user_agent
|
|
197
|
+
#
|
|
198
|
+
# @return [AntiCaptcha::HCaptchaSolution] The solution of the HCaptcha.
|
|
199
|
+
#
|
|
200
|
+
def decode_h_captcha!(options, proxy = nil)
|
|
201
|
+
task = create_task!('HCaptchaTask', options, proxy)
|
|
202
|
+
task_result = get_task_result!(task['taskId'])
|
|
203
|
+
AntiCaptcha::HCaptchaSolution.new(task_result)
|
|
204
|
+
end
|
|
205
|
+
|
|
170
206
|
# Creates a task for solving the selected CAPTCHA type.
|
|
171
207
|
#
|
|
172
208
|
# @param [String] type The type of the CAPTCHA.
|
|
@@ -249,10 +285,17 @@ module AntiCaptcha
|
|
|
249
285
|
websitePublicKey: options[:website_public_key],
|
|
250
286
|
}
|
|
251
287
|
|
|
288
|
+
when 'HCaptchaTask'
|
|
289
|
+
args[:task] = {
|
|
290
|
+
type: 'HCaptchaTask',
|
|
291
|
+
websiteURL: options[:website_url],
|
|
292
|
+
websiteKey: options[:website_key],
|
|
293
|
+
}
|
|
294
|
+
|
|
252
295
|
else
|
|
253
296
|
message = "Invalid task type: '#{type}'. Allowed types: " +
|
|
254
297
|
"#{SUPPORTED_TASKS.join(', ')}"
|
|
255
|
-
raise AntiCaptcha.
|
|
298
|
+
raise AntiCaptcha::ArgumentError.new(message)
|
|
256
299
|
end
|
|
257
300
|
|
|
258
301
|
if PROXYABLE_TASKS.include?(type)
|
|
@@ -281,7 +324,7 @@ module AntiCaptcha
|
|
|
281
324
|
# @return [Hash] Information about the task.
|
|
282
325
|
#
|
|
283
326
|
def get_task_result!(task_id)
|
|
284
|
-
raise AntiCaptcha.
|
|
327
|
+
raise AntiCaptcha::Error.new('taskId not received from Anti Captcha.') unless task_id
|
|
285
328
|
|
|
286
329
|
started_at = Time.now
|
|
287
330
|
|
|
@@ -317,6 +360,11 @@ module AntiCaptcha
|
|
|
317
360
|
# 6 - Recaptcha Proxyless task.
|
|
318
361
|
# 7 - Funcaptcha task.
|
|
319
362
|
# 10 - Funcaptcha Proxyless task.
|
|
363
|
+
# 18 - Recaptcha V3 s0.3
|
|
364
|
+
# 19 - Recaptcha V3 s0.7
|
|
365
|
+
# 20 - Recaptcha V3 s0.9
|
|
366
|
+
# 21 - hCaptcha Proxy-On
|
|
367
|
+
# 22 - hCaptcha Proxyless
|
|
320
368
|
#
|
|
321
369
|
# @return [Hash] Information about the queue.
|
|
322
370
|
#
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module AntiCaptcha
|
|
2
|
+
class HCaptchaSolution < AntiCaptcha::Solution
|
|
3
|
+
attr_accessor :g_recaptcha_response
|
|
4
|
+
|
|
5
|
+
def initialize(task_result = nil)
|
|
6
|
+
super
|
|
7
|
+
|
|
8
|
+
if task_result
|
|
9
|
+
@g_recaptcha_response = task_result.api_result['solution']['gRecaptchaResponse']
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/anti_captcha/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: anti_captcha
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Infosimples
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-
|
|
11
|
+
date: 2020-08-16 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -75,6 +75,7 @@ files:
|
|
|
75
75
|
- lib/anti_captcha/errors.rb
|
|
76
76
|
- lib/anti_captcha/http.rb
|
|
77
77
|
- lib/anti_captcha/models/fun_captcha_solution.rb
|
|
78
|
+
- lib/anti_captcha/models/h_captcha_solution.rb
|
|
78
79
|
- lib/anti_captcha/models/image_to_text_solution.rb
|
|
79
80
|
- lib/anti_captcha/models/no_captcha_solution.rb
|
|
80
81
|
- lib/anti_captcha/models/recaptcha_v3_solution.rb
|