anti_captcha 2.4.0 → 2.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c007c351a8655684c2f4680ead884429b8bea0ebd1fb33568119b15b477fcc76
4
- data.tar.gz: 38267b78fb266cbb281a3d28db9cf32633398798a270bdc9e2bbd4f87cc2d84a
3
+ metadata.gz: 7911a78f0b2ccdcb075555ea6ea96aa2abc6914311b792a4b2579ec1a3bc8901
4
+ data.tar.gz: f2e2df9d4ba1042fed67fed6d670dd6c22fc097f0856fa61e1da17a74483043c
5
5
  SHA512:
6
- metadata.gz: 6bd0a5e3759806d4d88285d819a2d18738a47d560d2a4a25ab6497d1a7d12b3e07a34f0e7c2d1ac5755a1b7238a975fc45b49594019076f0fd53584dee67e085
7
- data.tar.gz: 43a55d65f865c263b0fa732984a085b92ae5936530f8d6f6cc5a7e619e261629a3c4991907a85838b76968e73827270d3e580938c9adea23280a27a52e000ab4
6
+ metadata.gz: f1915d353fe91b85276cb5ace41c09b3762b8313c2903ab064f2f9fdb6572b151bfd2357f6a80f6883e4922773aeb096d3cca57c2939b309f093ef4f844cf181
7
+ data.tar.gz: cf6cdc10ac27031ccd362d8fb15da2af3d4e77cc849a4ab905854c831977b20c89a38fd47cad502f778d6b359493a45d4add2d0f5512f1984b0dcda23822e3a7
data/README.md CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  AntiCaptcha is a Ruby API for Anti-Captcha - [Anti-Captcha.com](http://getcaptchasolution.com/ipuz16klxh)
4
4
 
5
- > We suggest you to also check the recommended CAPTCHA provider DeathByCaptcha.
6
- > The gem for this provider is available at https://github.com/infosimples/deathbycaptcha.
7
-
8
5
  ## Installation
9
6
 
10
7
  Add this line to your application's Gemfile:
@@ -94,8 +91,8 @@ solution.g_recaptcha_response
94
91
  solution = client.decode_recaptcha_v3!(
95
92
  website_key: 'xyz',
96
93
  website_url: 'http://example.com/example=1',
97
- min_score: 0.3,
98
94
  page_action: 'myverify',
95
+ min_score: 0.3, # OPTIONAL
99
96
  # is_enterprise: false, # OPTIONAL
100
97
  )
101
98
 
@@ -242,6 +239,33 @@ solution.v4['captcha_output']
242
239
  - `proxy_password`: optional parameter. The proxy password.
243
240
  - `user_agent`: optional parameter. The user agent.
244
241
 
242
+ #### Cloudflare Turnstile
243
+
244
+ ```ruby
245
+ solution = client.decode_turnstile!(
246
+ website_key: 'xyz',
247
+ website_url: 'http://example.com/example=1',
248
+ # proxy_type: 'http', # OPTIONAL
249
+ # proxy_address: '127.0.0.1', # OPTIONAL
250
+ # proxy_port: '8080', # OPTIONAL
251
+ # proxy_login: 'proxyLoginHere', # OPTIONAL
252
+ # proxy_password: 'proxyPasswordHere', # OPTIONAL
253
+ )
254
+
255
+ solution.token
256
+ "0.vtJqmZnvobaUzK2i2PyKaSqHELYtBZfRoPwMvLMdA81WL_9G0vCO3y2VQVIeVplG0mxYF7uX......."
257
+ ```
258
+
259
+ *Parameters:*
260
+
261
+ - `website_key`: the site key for the Turnstile.
262
+ - `website_url`: the URL of the page with the Turnstile challenge.
263
+ - `proxy_type`: optional parameter. Proxy connection protocol.
264
+ - `proxy_address`: optional parameter. The proxy address.
265
+ - `proxy_port`: optional parameter. The proxy port.
266
+ - `proxy_login`: optional parameter. The proxy login.
267
+ - `proxy_password`: optional parameter. The proxy password.
268
+
245
269
  ### 3. Report an incorrectly solved image CAPTCHA for a refund
246
270
 
247
271
  It is only possible to report incorrectly solved image CAPTCHAs.
@@ -276,6 +300,8 @@ Queue IDs:
276
300
  - `23` Recaptcha Enterprise V2 with proxy
277
301
  - `24` Recaptcha Enterprise V2 without proxy
278
302
  - `25` AntiGateTask
303
+ - `26` Turnstile with proxy
304
+ - `27` Turnstile without proxy
279
305
 
280
306
  ```ruby
281
307
  client.get_queue_stats!(queue_id)
@@ -290,7 +316,7 @@ avoid conflicts with other gems.
290
316
 
291
317
  ### Input image format
292
318
 
293
- Any format you use in the `decode_image!` method (`file`, `path`, `body`, `body64`)
319
+ Any format you use in the `decode_image!` method (`file`, `path`, `body` or `body64`)
294
320
  will always be converted to a `body64`, which is a base64-encoded binary string.
295
321
  So, if you already have this format on your end, there is no need for convertions
296
322
  before calling the API.
@@ -4,7 +4,7 @@ module AntiCaptcha
4
4
  #
5
5
  class Client
6
6
  BASE_URL = 'https://api.anti-captcha.com/:action'
7
- PROXYABLE_TASKS = %w(RecaptchaV2Task FunCaptchaTask HCaptchaTask GeeTestTask)
7
+ PROXYABLE_TASKS = %w(RecaptchaV2Task FunCaptchaTask HCaptchaTask GeeTestTask TurnstileTask)
8
8
 
9
9
  attr_accessor :client_key, :timeout, :polling
10
10
 
@@ -246,6 +246,40 @@ module AntiCaptcha
246
246
  AntiCaptcha::GeetestSolution.new(task_result)
247
247
  end
248
248
 
249
+ #
250
+ # Decodes a Turnstile CAPTCHA.
251
+ #
252
+ # @see `AntiCaptcha::Client#decode_turnstile!`
253
+ #
254
+ def decode_turnstile(options, proxy = nil)
255
+ decode_turnstile!(options, proxy)
256
+ rescue
257
+ AntiCaptcha::TurnstileSolution.new
258
+ end
259
+
260
+ #
261
+ # Decodes a Turnstile CAPTCHA.
262
+ #
263
+ # @param [Hash] options Options hash.
264
+ # @option options [String] :website_url
265
+ # @option options [String] :website_key
266
+ #
267
+ # @param [Hash] proxy Not mandatory. A hash with configs of the proxy that
268
+ # has to be used. Defaults to `nil`.
269
+ # @option proxy [String] :proxy_type
270
+ # @option proxy [String] :proxy_address
271
+ # @option proxy [String] :proxy_port
272
+ # @option proxy [String] :proxy_login
273
+ # @option proxy [String] :proxy_password
274
+ #
275
+ # @return [AntiCaptcha::TurnstileSolution] The solution of the Turnstile.
276
+ #
277
+ def decode_turnstile!(options, proxy = nil)
278
+ task = create_task!('TurnstileTask', options, proxy)
279
+ task_result = get_task_result!(task['taskId'])
280
+ AntiCaptcha::TurnstileSolution.new(task_result)
281
+ end
282
+
249
283
  # Creates a task for solving the selected CAPTCHA type.
250
284
  #
251
285
  # @param [String] type The type of the CAPTCHA.
@@ -349,6 +383,13 @@ module AntiCaptcha
349
383
  args[:version] = options[:version] if !options[:version].nil?
350
384
  args[:initParameters] = options[:init_parameters] if !options[:init_parameters].nil?
351
385
 
386
+ when 'TurnstileTask'
387
+ args[:task] = {
388
+ type: 'TurnstileTask',
389
+ websiteURL: options[:website_url],
390
+ websiteKey: options[:website_key],
391
+ }
392
+
352
393
  else
353
394
  message = "Invalid task type: '#{type}'."
354
395
  raise AntiCaptcha::ArgumentError.new(message)
@@ -421,6 +462,8 @@ module AntiCaptcha
421
462
  # 20 - Recaptcha V3 s0.9
422
463
  # 21 - hCaptcha Proxy-On
423
464
  # 22 - hCaptcha Proxyless
465
+ # 26 - Turnstile Proxy-On
466
+ # 27 - Turnstile Proxyless
424
467
  #
425
468
  # @return [Hash] Information about the queue.
426
469
  #
@@ -0,0 +1,13 @@
1
+ module AntiCaptcha
2
+ class TurnstileSolution < AntiCaptcha::Solution
3
+ attr_accessor :token
4
+
5
+ def initialize(task_result = nil)
6
+ super
7
+
8
+ if task_result
9
+ @token = task_result.api_result['solution']['token']
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,4 +1,4 @@
1
1
  module AntiCaptcha
2
- VERSION = "2.4.0"
2
+ VERSION = "2.5.0"
3
3
  USER_AGENT = "AntiCaptcha/Ruby v#{VERSION}"
4
4
  end
data/lib/anti_captcha.rb CHANGED
@@ -38,6 +38,7 @@ require 'anti_captcha/models/recaptcha_v3_solution'
38
38
  require 'anti_captcha/models/fun_captcha_solution'
39
39
  require 'anti_captcha/models/h_captcha_solution'
40
40
  require 'anti_captcha/models/geetest_solution'
41
+ require 'anti_captcha/models/turnstile_solution'
41
42
  require 'anti_captcha/models/task_result'
42
43
  require 'anti_captcha/client'
43
44
  require 'anti_captcha/version'
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.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Infosimples
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-30 00:00:00.000000000 Z
11
+ date: 2024-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -82,12 +82,13 @@ files:
82
82
  - lib/anti_captcha/models/recaptcha_v3_solution.rb
83
83
  - lib/anti_captcha/models/solution.rb
84
84
  - lib/anti_captcha/models/task_result.rb
85
+ - lib/anti_captcha/models/turnstile_solution.rb
85
86
  - lib/anti_captcha/version.rb
86
87
  homepage: https://github.com/infosimples/anti_captcha
87
88
  licenses:
88
89
  - MIT
89
90
  metadata: {}
90
- post_install_message:
91
+ post_install_message:
91
92
  rdoc_options: []
92
93
  require_paths:
93
94
  - lib
@@ -102,8 +103,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  - !ruby/object:Gem::Version
103
104
  version: '0'
104
105
  requirements: []
105
- rubygems_version: 3.1.4
106
- signing_key:
106
+ rubygems_version: 3.5.6
107
+ signing_key:
107
108
  specification_version: 4
108
109
  summary: Ruby API for Anti Captcha (CAPTCHA Solver as a Service)
109
110
  test_files: []