ruby-2captcha 1.1.4 → 1.1.6

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.
Binary file
Binary file
@@ -0,0 +1,9 @@
1
+ require 'api_2captcha'
2
+
3
+ client = Api2Captcha.new("YOUR_API_KEY")
4
+
5
+ result = client.normal({
6
+ image: './media/normal_2.jpg',
7
+ })
8
+
9
+ puts "Result: #{result.inspect}"
@@ -0,0 +1,10 @@
1
+ require 'api_2captcha'
2
+
3
+ client = Api2Captcha.new("YOUR_API_KEY")
4
+
5
+ result = client.recaptcha_v2({
6
+ googlekey: '6LfD3PIbAAAAAJs_eEHvoOl75_83eXSqpPSRFJ_u',
7
+ pageurl: 'https://2captcha.com/demo/recaptcha-v2',
8
+ })
9
+
10
+ puts "Result: #{result.inspect}"
@@ -0,0 +1,10 @@
1
+ require 'api_2captcha'
2
+
3
+ client = Api2Captcha.new("YOUR_API_KEY")
4
+
5
+ result = client.tencent({
6
+ app_id: "197326679",
7
+ pageurl: "https://mysite.com/page/with/tencent"
8
+ })
9
+
10
+ puts "Result: #{result.inspect}"
@@ -23,7 +23,7 @@ module Api2Captcha
23
23
  @default_timeout = 120
24
24
  @recaptcha_timeout = 600
25
25
  @polling_interval = 10
26
- @soft_id = 0
26
+ @soft_id = 4584
27
27
  @domain = DEFAULT_DOMAIN
28
28
  end
29
29
 
@@ -134,7 +134,7 @@ module Api2Captcha
134
134
  end
135
135
 
136
136
  def grid(params)
137
- params["recaptcha"] = 1
137
+ params[:recaptcha] = 1
138
138
  solve("post", **params)
139
139
  end
140
140
 
@@ -171,7 +171,7 @@ module Api2Captcha
171
171
  end
172
172
 
173
173
  def audio(params)
174
- audio = params.delete("audio")
174
+ audio = params.delete(:audio)
175
175
  audio_content = File.file?(audio) ? File.binread(audio) : audio
176
176
 
177
177
  params = params.merge(
@@ -201,6 +201,18 @@ module Api2Captcha
201
201
  solve("friendly_captcha", **params)
202
202
  end
203
203
 
204
+ def cutcaptcha(params)
205
+ solve("cutcaptcha", **params)
206
+ end
207
+
208
+ def tencent(params)
209
+ solve("tencent", **params)
210
+ end
211
+
212
+ def atb_captcha(params)
213
+ solve("atb_captcha", **params)
214
+ end
215
+
204
216
  private
205
217
 
206
218
  def base_url
@@ -223,16 +235,24 @@ module Api2Captcha
223
235
  image = params.delete("image")
224
236
  hint_image = params.delete("hint_image")
225
237
 
226
- image_content = get_image_content(image)
227
- hint_image_content = get_image_content(hint_image) if hint_image
238
+ image_content = if base64_encoded?(image)
239
+ image
240
+ else
241
+ Base64.strict_encode64(get_image_content(image))
242
+ end
243
+
244
+ hint_image_content = if hint_image
245
+ base64_encoded?(hint_image) ? hint_image : Base64.strict_encode64(get_image_content(hint_image))
246
+ end
247
+
228
248
  result_params = {
229
249
  "method" => "base64",
230
- "body" => Base64.strict_encode64(image_content),
250
+ "body" => image_content,
231
251
  "filename" => File.basename(image),
232
252
  "ext" => File.extname(image).delete(".")
233
253
  }
234
254
 
235
- result_params["imginstructions"] = Base64.strict_encode64(hint_image_content) if hint_image_content
255
+ result_params["imginstructions"] = hint_image_content if hint_image_content
236
256
  params.merge(result_params)
237
257
  end
238
258
 
@@ -242,6 +262,10 @@ module Api2Captcha
242
262
  image
243
263
  end
244
264
 
265
+ def base64_encoded?(string)
266
+ string.is_a?(String) && string.match(/\A[A-Za-z0-9+\/=]+\z/) && (string.length % 4).zero?
267
+ end
268
+
245
269
  def download_image(url)
246
270
  response = URI.open(url)
247
271
  if response.status[0] != '200'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Api2Captcha
4
- VERSION = "1.1.4"
4
+ VERSION = "1.1.6"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-2captcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - 2captcha.com
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-23 00:00:00.000000000 Z
11
+ date: 2024-11-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby package for easy integration with the API of 2captcha captcha solving
14
14
  service to bypass recaptcha, hcaptcha, funcaptcha, geetest and solve any other captchas.
@@ -29,6 +29,16 @@ files:
29
29
  - README.ru.md
30
30
  - Rakefile
31
31
  - api_2captcha.gemspec
32
+ - examples/atb_captcha_example.rb
33
+ - examples/audio_example.rb
34
+ - examples/grid_captcha_example.rb
35
+ - examples/media/example.mp3
36
+ - examples/media/normal_2.jpg
37
+ - examples/media/recaptchaGrid4x4.jpg
38
+ - examples/media/recaptchaGridImginstructions4x4.jpg
39
+ - examples/normal_captcha_example.rb
40
+ - examples/recaptcha_v2_example.rb
41
+ - examples/tencent_example.rb
32
42
  - lib/api_2captcha.rb
33
43
  - lib/api_2captcha/api2captcha_exceptions.rb
34
44
  - lib/api_2captcha/client.rb
@@ -42,6 +52,10 @@ metadata:
42
52
  source_code_uri: https://github.com/2captcha/2captcha-ruby
43
53
  changelog_uri: https://github.com/2captcha/2captcha-ruby/releases
44
54
  github_repo: ssh://github.com/2captcha/2captcha-ruby
55
+ bug_tracker_uri: https://github.com/2captcha/2captcha-ruby/issues
56
+ keywords: 2captcha, captcha solver, captcha bypass, Ruby, automation, CAPTCHA API,
57
+ CAPTCHA recognition, anti-captcha, reCAPTCHA, OCR, image recognition, human verification,
58
+ bot protection, recaptcha
45
59
  post_install_message:
46
60
  rdoc_options: []
47
61
  require_paths: