ruby-2captcha 1.1.6 → 1.2.1
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/.rspec_status +16 -7
- data/.ruby-version +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +222 -4
- data/README.ru.md +227 -0
- data/api_2captcha.gemspec +1 -1
- data/examples/alibaba_example.rb +16 -0
- data/examples/altcha_example.rb +12 -0
- data/examples/amazon_waf_example.rb +14 -0
- data/examples/basilisk_example.rb +15 -0
- data/examples/binance_example.rb +17 -0
- data/examples/canvas_example.rb +13 -0
- data/examples/captchafox_example.rb +20 -0
- data/examples/capy_example.rb +11 -0
- data/examples/cloudflare_turnstile_example.rb +15 -0
- data/examples/coordinates_example.rb +12 -0
- data/examples/cut_captcha_example.rb +11 -0
- data/examples/cyber_siara_example.rb +10 -0
- data/examples/datadome_example.rb +12 -0
- data/examples/drag_drop_example.rb +24 -0
- data/examples/friendly_captcha_example.rb +10 -0
- data/examples/funcaptcha_example.rb +10 -0
- data/examples/geetest_example.rb +12 -0
- data/examples/geetest_v4_example.rb +10 -0
- data/examples/hcaptcha_example.rb +10 -0
- data/examples/hunt_example.rb +17 -0
- data/examples/imperva_example.rb +20 -0
- data/examples/key_captcha_example.rb +13 -0
- data/examples/lemin_example.rb +12 -0
- data/examples/media/drag_drop/background.jpeg +0 -0
- data/examples/media/drag_drop/image1.jpeg +0 -0
- data/examples/media/drag_drop/image2.jpeg +0 -0
- data/examples/media/temu/body.png +0 -0
- data/examples/media/temu/part1.png +0 -0
- data/examples/media/temu/part2.png +0 -0
- data/examples/media/temu/part3.png +0 -0
- data/examples/mt_captcha_example.rb +10 -0
- data/examples/normal_captcha_example.rb +4 -2
- data/examples/prosopo_example.rb +16 -0
- data/examples/recaptcha_v2_example.rb +1 -1
- data/examples/recaptcha_v3_example.rb +18 -0
- data/examples/rotate_example.rb +13 -0
- data/examples/temu_example.rb +28 -0
- data/examples/text_example.rb +23 -0
- data/examples/tspd_example.rb +19 -0
- data/examples/vkcaptcha_example.ru +10 -0
- data/examples/vkimage_example.rb +10 -0
- data/examples/yandex_example.rb +10 -0
- data/examples/yidun_example.rb +15 -0
- data/howto.txt +8 -0
- data/lib/api_2captcha/client.rb +87 -30
- data/lib/api_2captcha/version.rb +1 -1
- metadata +49 -7
data/lib/api_2captcha/client.rb
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
2
|
+
|
|
3
|
+
require "net/http"
|
|
4
|
+
require "uri"
|
|
5
|
+
require "json"
|
|
6
|
+
require "base64"
|
|
7
|
+
require "open-uri"
|
|
7
8
|
|
|
8
9
|
module Api2Captcha
|
|
9
10
|
class Client
|
|
@@ -42,12 +43,15 @@ module Api2Captcha
|
|
|
42
43
|
complete_params = get_params(params)
|
|
43
44
|
captcha_id = send_request(complete_params)
|
|
44
45
|
return captcha_id if return_id
|
|
46
|
+
|
|
45
47
|
get_result(captcha_id)
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
def send(*args)
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
unless args.size == 1
|
|
52
|
+
raise ArgumentError,
|
|
53
|
+
"Invalid arguments of the send method"
|
|
54
|
+
end
|
|
51
55
|
|
|
52
56
|
arg = args.first
|
|
53
57
|
if arg.is_a?(String)
|
|
@@ -94,7 +98,7 @@ module Api2Captcha
|
|
|
94
98
|
|
|
95
99
|
def get_balance
|
|
96
100
|
response = make_res_request({ "action" => "getbalance" }, "getbalance")
|
|
97
|
-
|
|
101
|
+
response["request"].to_f
|
|
98
102
|
end
|
|
99
103
|
|
|
100
104
|
def normal(params)
|
|
@@ -134,7 +138,7 @@ module Api2Captcha
|
|
|
134
138
|
end
|
|
135
139
|
|
|
136
140
|
def grid(params)
|
|
137
|
-
params[
|
|
141
|
+
params["recaptcha"] = 1
|
|
138
142
|
solve("post", **params)
|
|
139
143
|
end
|
|
140
144
|
|
|
@@ -170,6 +174,14 @@ module Api2Captcha
|
|
|
170
174
|
solve("amazon_waf", **params)
|
|
171
175
|
end
|
|
172
176
|
|
|
177
|
+
def vkimage(params)
|
|
178
|
+
solve("vkimage", **params)
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def vkcaptcha(params)
|
|
182
|
+
solve("vkcaptcha", **params)
|
|
183
|
+
end
|
|
184
|
+
|
|
173
185
|
def audio(params)
|
|
174
186
|
audio = params.delete(:audio)
|
|
175
187
|
audio_content = File.file?(audio) ? File.binread(audio) : audio
|
|
@@ -213,6 +225,54 @@ module Api2Captcha
|
|
|
213
225
|
solve("atb_captcha", **params)
|
|
214
226
|
end
|
|
215
227
|
|
|
228
|
+
def prosopo(params)
|
|
229
|
+
solve("prosopo", **params)
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
def captchafox(params)
|
|
233
|
+
solve("captchafox", **params)
|
|
234
|
+
end
|
|
235
|
+
|
|
236
|
+
def altcha(params)
|
|
237
|
+
solve("altcha", **params)
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
def temu(params)
|
|
241
|
+
solve("temuimage", **params)
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
def binance(params)
|
|
245
|
+
solve("binance", **params)
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
def hunt(params)
|
|
249
|
+
solve("hunt", **params)
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
def tspd(params)
|
|
253
|
+
solve("tspd", **params)
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
def basilisk(params)
|
|
257
|
+
solve("basilisk", **params)
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
def alibaba(params)
|
|
261
|
+
solve("alibaba", **params)
|
|
262
|
+
end
|
|
263
|
+
|
|
264
|
+
def yidun(params)
|
|
265
|
+
solve("yidun", **params)
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def drag_drop(params)
|
|
269
|
+
solve("drag_drop", **params)
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
def imperva(params)
|
|
273
|
+
solve("incapsula", **params)
|
|
274
|
+
end
|
|
275
|
+
|
|
216
276
|
private
|
|
217
277
|
|
|
218
278
|
def base_url
|
|
@@ -222,7 +282,7 @@ module Api2Captcha
|
|
|
222
282
|
def send_request(params)
|
|
223
283
|
uri = URI("#{base_url}/in.php")
|
|
224
284
|
req = Net::HTTP::Post.new(uri)
|
|
225
|
-
req.content_type =
|
|
285
|
+
req.content_type = "application/json"
|
|
226
286
|
req.body = params.to_json
|
|
227
287
|
captcha_id = get_captcha_id(make_request(uri, req))
|
|
228
288
|
end
|
|
@@ -236,14 +296,14 @@ module Api2Captcha
|
|
|
236
296
|
hint_image = params.delete("hint_image")
|
|
237
297
|
|
|
238
298
|
image_content = if base64_encoded?(image)
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
299
|
+
image
|
|
300
|
+
else
|
|
301
|
+
Base64.strict_encode64(get_image_content(image))
|
|
302
|
+
end
|
|
243
303
|
|
|
244
304
|
hint_image_content = if hint_image
|
|
245
|
-
|
|
246
|
-
|
|
305
|
+
base64_encoded?(hint_image) ? hint_image : Base64.strict_encode64(get_image_content(hint_image))
|
|
306
|
+
end
|
|
247
307
|
|
|
248
308
|
result_params = {
|
|
249
309
|
"method" => "base64",
|
|
@@ -257,20 +317,20 @@ module Api2Captcha
|
|
|
257
317
|
end
|
|
258
318
|
|
|
259
319
|
def get_image_content(image)
|
|
260
|
-
return download_image(image) if image.start_with?(
|
|
320
|
+
return download_image(image) if image.start_with?("http")
|
|
261
321
|
return File.binread(image) if File.file?(image)
|
|
322
|
+
|
|
262
323
|
image
|
|
263
324
|
end
|
|
264
325
|
|
|
265
326
|
def base64_encoded?(string)
|
|
266
|
-
string.is_a?(String) && string.match(
|
|
327
|
+
string.is_a?(String) && string.match(%r{\A[A-Za-z0-9+/=]+\z}) && (string.length % 4).zero?
|
|
267
328
|
end
|
|
268
329
|
|
|
269
330
|
def download_image(url)
|
|
270
331
|
response = URI.open(url)
|
|
271
|
-
if response.status[0] !=
|
|
272
|
-
|
|
273
|
-
end
|
|
332
|
+
raise StandardError, "File could not be downloaded from url: #{url}" if response.status[0] != "200"
|
|
333
|
+
|
|
274
334
|
response.read
|
|
275
335
|
end
|
|
276
336
|
|
|
@@ -284,11 +344,10 @@ module Api2Captcha
|
|
|
284
344
|
case response
|
|
285
345
|
when Net::HTTPSuccess
|
|
286
346
|
response_json = JSON.parse(response.body.strip)
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
end
|
|
347
|
+
raise ApiException, "API Error: #{response_json["request"]}" unless response_json["status"] == 1
|
|
348
|
+
|
|
349
|
+
response_json["request"]
|
|
350
|
+
|
|
292
351
|
else
|
|
293
352
|
raise NetworkException, "Network Error: #{response.code.to_i}"
|
|
294
353
|
end
|
|
@@ -309,19 +368,17 @@ module Api2Captcha
|
|
|
309
368
|
def make_res_request(request, action)
|
|
310
369
|
uri = URI("#{base_url}/res.php?key=#{@api_key}&action=#{action}&json=1")
|
|
311
370
|
req = Net::HTTP::Post.new(uri)
|
|
312
|
-
req.content_type =
|
|
371
|
+
req.content_type = "application/json"
|
|
313
372
|
req.body = request.to_json
|
|
314
373
|
|
|
315
374
|
response = make_request(uri, req)
|
|
316
375
|
|
|
317
376
|
case response
|
|
318
377
|
when Net::HTTPSuccess
|
|
319
|
-
|
|
378
|
+
JSON.parse(response.body)
|
|
320
379
|
else
|
|
321
380
|
raise Api2Captcha::NetworkException, "Network Error: #{response.code.to_i}"
|
|
322
381
|
end
|
|
323
382
|
end
|
|
324
383
|
end
|
|
325
384
|
end
|
|
326
|
-
|
|
327
|
-
|
data/lib/api_2captcha/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ruby-2captcha
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1
|
|
4
|
+
version: 1.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- 2captcha.com
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-10-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Ruby package for easy integration with the API of 2captcha captcha solving
|
|
14
|
-
service to bypass recaptcha,
|
|
14
|
+
service to bypass recaptcha, funcaptcha, geetest and solve any other captchas.
|
|
15
15
|
email:
|
|
16
16
|
- info@2captcha.com
|
|
17
17
|
executables: []
|
|
@@ -29,16 +29,58 @@ files:
|
|
|
29
29
|
- README.ru.md
|
|
30
30
|
- Rakefile
|
|
31
31
|
- api_2captcha.gemspec
|
|
32
|
+
- examples/alibaba_example.rb
|
|
33
|
+
- examples/altcha_example.rb
|
|
34
|
+
- examples/amazon_waf_example.rb
|
|
32
35
|
- examples/atb_captcha_example.rb
|
|
33
36
|
- examples/audio_example.rb
|
|
37
|
+
- examples/basilisk_example.rb
|
|
38
|
+
- examples/binance_example.rb
|
|
39
|
+
- examples/canvas_example.rb
|
|
40
|
+
- examples/captchafox_example.rb
|
|
41
|
+
- examples/capy_example.rb
|
|
42
|
+
- examples/cloudflare_turnstile_example.rb
|
|
43
|
+
- examples/coordinates_example.rb
|
|
44
|
+
- examples/cut_captcha_example.rb
|
|
45
|
+
- examples/cyber_siara_example.rb
|
|
46
|
+
- examples/datadome_example.rb
|
|
47
|
+
- examples/drag_drop_example.rb
|
|
48
|
+
- examples/friendly_captcha_example.rb
|
|
49
|
+
- examples/funcaptcha_example.rb
|
|
50
|
+
- examples/geetest_example.rb
|
|
51
|
+
- examples/geetest_v4_example.rb
|
|
34
52
|
- examples/grid_captcha_example.rb
|
|
53
|
+
- examples/hcaptcha_example.rb
|
|
54
|
+
- examples/hunt_example.rb
|
|
55
|
+
- examples/imperva_example.rb
|
|
56
|
+
- examples/key_captcha_example.rb
|
|
57
|
+
- examples/lemin_example.rb
|
|
58
|
+
- examples/media/drag_drop/background.jpeg
|
|
59
|
+
- examples/media/drag_drop/image1.jpeg
|
|
60
|
+
- examples/media/drag_drop/image2.jpeg
|
|
35
61
|
- examples/media/example.mp3
|
|
36
62
|
- examples/media/normal_2.jpg
|
|
37
63
|
- examples/media/recaptchaGrid4x4.jpg
|
|
38
64
|
- examples/media/recaptchaGridImginstructions4x4.jpg
|
|
65
|
+
- examples/media/temu/body.png
|
|
66
|
+
- examples/media/temu/part1.png
|
|
67
|
+
- examples/media/temu/part2.png
|
|
68
|
+
- examples/media/temu/part3.png
|
|
69
|
+
- examples/mt_captcha_example.rb
|
|
39
70
|
- examples/normal_captcha_example.rb
|
|
71
|
+
- examples/prosopo_example.rb
|
|
40
72
|
- examples/recaptcha_v2_example.rb
|
|
73
|
+
- examples/recaptcha_v3_example.rb
|
|
74
|
+
- examples/rotate_example.rb
|
|
75
|
+
- examples/temu_example.rb
|
|
41
76
|
- examples/tencent_example.rb
|
|
77
|
+
- examples/text_example.rb
|
|
78
|
+
- examples/tspd_example.rb
|
|
79
|
+
- examples/vkcaptcha_example.ru
|
|
80
|
+
- examples/vkimage_example.rb
|
|
81
|
+
- examples/yandex_example.rb
|
|
82
|
+
- examples/yidun_example.rb
|
|
83
|
+
- howto.txt
|
|
42
84
|
- lib/api_2captcha.rb
|
|
43
85
|
- lib/api_2captcha/api2captcha_exceptions.rb
|
|
44
86
|
- lib/api_2captcha/client.rb
|
|
@@ -56,7 +98,7 @@ metadata:
|
|
|
56
98
|
keywords: 2captcha, captcha solver, captcha bypass, Ruby, automation, CAPTCHA API,
|
|
57
99
|
CAPTCHA recognition, anti-captcha, reCAPTCHA, OCR, image recognition, human verification,
|
|
58
100
|
bot protection, recaptcha
|
|
59
|
-
post_install_message:
|
|
101
|
+
post_install_message:
|
|
60
102
|
rdoc_options: []
|
|
61
103
|
require_paths:
|
|
62
104
|
- lib
|
|
@@ -71,8 +113,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
71
113
|
- !ruby/object:Gem::Version
|
|
72
114
|
version: '0'
|
|
73
115
|
requirements: []
|
|
74
|
-
rubygems_version: 3.
|
|
75
|
-
signing_key:
|
|
116
|
+
rubygems_version: 3.4.1
|
|
117
|
+
signing_key:
|
|
76
118
|
specification_version: 4
|
|
77
119
|
summary: 2Captcha API wrapper for Ruby.
|
|
78
120
|
test_files: []
|