Class: Metabypass
Instance Attribute Summary collapse
-
#end_result ⇒ Object
Returns the value of attribute end_result.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#logger_file_path ⇒ Object
Returns the value of attribute logger_file_path.
Instance Method Summary collapse
-
#image_captcha(image, numeric = 0, minLen = 0, maxLen = 0) ⇒ Object
Image captcha requester.
-
#initialize(client_id, client_secret, email, password) ⇒ Metabypass
constructor
A new instance of Metabypass.
-
#recaptcha_invisible(url, siteKey) ⇒ Object
reCaptcha invisible requester.
-
#recaptcha_v2(url, siteKey) ⇒ Object
Simple reCaptcha v2 requester without handling the result.
-
#recaptcha_v2_handler(url, siteKey) ⇒ Object
reCaptcha v2 requester & result handler.
-
#recaptcha_v3(url, siteKey) ⇒ Object
reCaptcha v3 requester.
Methods inherited from Auth
Constructor Details
#initialize(client_id, client_secret, email, password) ⇒ Metabypass
18 19 20 21 22 23 |
# File 'lib/metabypass.rb', line 18 def initialize(client_id,client_secret,email,password) @end_result = nil @logger_file_path='metabypass.log' @logger = Logger.new(@logger_file_path) super(client_id,client_secret,email,password) end |
Instance Attribute Details
#end_result ⇒ Object
Returns the value of attribute end_result.
15 16 17 |
# File 'lib/metabypass.rb', line 15 def end_result @end_result end |
#logger ⇒ Object
Returns the value of attribute logger.
15 16 17 |
# File 'lib/metabypass.rb', line 15 def logger @logger end |
#logger_file_path ⇒ Object
Returns the value of attribute logger_file_path.
15 16 17 |
# File 'lib/metabypass.rb', line 15 def logger_file_path @logger_file_path end |
Instance Method Details
#image_captcha(image, numeric = 0, minLen = 0, maxLen = 0) ⇒ Object
Image captcha requester
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 54 55 56 57 |
# File 'lib/metabypass.rb', line 27 def image_captcha(image, numeric = 0, minLen = 0, maxLen = 0) @end_result=nil # Check if the image is a file or base64 if File.exist?(image) begin context = File.binread(image) base64EncodedFile = Base64.encode64(context).delete("\r\n") rescue Errno::ENOENT => e #logger ='file did not read' logger.error() false end elsif is_base64_format?(image) base64EncodedFile = image else #logger ='invalid image. pass image path or valid base64 of image' logger.error() false end image_captcha_requester(base64EncodedFile, numeric, minLen, maxLen) end |
#recaptcha_invisible(url, siteKey) ⇒ Object
reCaptcha invisible requester
117 118 119 120 |
# File 'lib/metabypass.rb', line 117 def recaptcha_invisible(url, siteKey) @end_result=nil re_captcha_invisible_requester(url, siteKey) end |
#recaptcha_v2(url, siteKey) ⇒ Object
Simple reCaptcha v2 requester without handling the result
61 62 63 64 65 |
# File 'lib/metabypass.rb', line 61 def recaptcha_v2(url, siteKey) @end_result=nil # This is just an API caller for developers recaptcha_v2_requester(url, siteKey) end |
#recaptcha_v2_handler(url, siteKey) ⇒ Object
reCaptcha v2 requester & result handler
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/metabypass.rb', line 69 def recaptcha_v2_handler(url, siteKey) @end_result=nil # Request reCaptcha v2 API recaptcha_response = recaptcha_v2_requester(url, siteKey) false unless recaptcha_response if recaptcha_response['data']['RecaptchaId'].nil? #logger mwssage='invalid reCaptcha v2 response. RecaptchaId not found in response body. ' logger.error() false end result=nil # Handle getting the result (max: 100 seconds) puts "to get result wait 10 seconds ... (to disable this message go to metabypass.rb file and comment line #{__LINE__})" 10.times do # Sleep for 10 seconds to get the result sleep(10) # Request get result API result = recaptchav2_get_result_requester(recaptcha_response['data']['RecaptchaId']) # puts result.inspect # Show get result response if result['status_code'] == 200 break else @end_result = false puts "reCAPTCHA result not ready. Wait 10 seconds again... (to disable this message go to metabypass.rb file and comment line #{__LINE__})" end end result end |
#recaptcha_v3(url, siteKey) ⇒ Object
reCaptcha v3 requester
110 111 112 113 |
# File 'lib/metabypass.rb', line 110 def recaptcha_v3(url, siteKey) @end_result=nil recaptcha_v3_requester(url, siteKey) end |