5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/modules/captcha_solver.rb', line 5
def image_captcha_requester(image, numeric = 0, min_len = 0, max_len = 0)
request_url = 'https://app.metabypass.tech/CaptchaSolver/api/v1/services/captchaSolver'
params = {
'image' => image,
'numeric' => numeric,
'min_len' => min_len,
'max_len' => max_len
}
= {
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' + @access_token.delete("\r\n"),
'Accept' => 'application/json'
}
response = send_request(request_url, params, 'POST', )
if response.empty?
message = 'error! server response is empty'
logger.error(message)
false
end
= JSON.parse(response['headers'])
response_body = JSON.parse(response['body'])
if ['http_code'] == 200
if response_body['status_code'].to_i == 200
@end_result = response_body['data']['result']
end
response_body
elsif ['http_code'] == 401
status = generate_access_token
if status == false
puts 'unauth'
exit
end
image_captcha_requester(image, numeric, min_len, max_len)
else
message = 'error! image captcha'
logger.error(message)
false
end
end
|