lib/two_captcha/client.rb
def decode_recaptcha_v2!(options = {})
      started_at = Time.now

      fail(TwoCaptcha::GoogleKey) if options[:googlekey].empty?

      upload_options = {
        method: 'userrecaptcha',
        googlekey: options[:googlekey],
        pageurl: options[:pageurl]
      }
      decoded_captcha = upload(upload_options)

      # pool untill the answer is ready
      while decoded_captcha.text.to_s.empty?
        sleep([polling, 10].max) # sleep at least 10 seconds
        decoded_captcha = captcha(decoded_captcha.id)
        fail TwoCaptcha::Timeout if (Time.now - started_at) > timeout
      end

      decoded_captcha
    end
def decode_recaptcha_v2!(options = {})
      started_at = Time.now

      fail(TwoCaptcha::GoogleKey) if options[:googlekey].empty?

      upload_options = {
        method: 'userrecaptcha',
        googlekey: options[:googlekey],
        pageurl: options[:pageurl]
      }
      decoded_captcha = upload(upload_options)

      # pool untill the answer is ready
      while decoded_captcha.text.to_s.empty?
        sleep([polling, 10].max) # sleep at least 10 seconds
        decoded_captcha = captcha(decoded_captcha.id)
        fail TwoCaptcha::Timeout if (Time.now - started_at) > timeout
      end

      decoded_captcha
    end
def decode_recaptcha_v2! ( options = { } ) started_at = Time . now fail ( TwoCaptcha :: GoogleKey ) if options [ :googlekey ] . empty? upload_options = { method : 'userrecaptcha' , googlekey : options [ :googlekey ] , pageurl : options [ :pageurl ] } decoded_captcha = upload ( upload_options ) # pool untill the answer is ready while decoded_captcha . text . to_s . empty? sleep ( [ polling , 10 ] . max ) # sleep at least 10 seconds decoded_captcha = captcha ( decoded_captcha . id ) fail TwoCaptcha :: Timeout if ( Time . now - started_at ) > timeout end decoded_captcha end
Solve reCAPTCHA v2.

 @param [Hash] options Options hash.
 @option options [String]  :googlekey The open key of the site in which recaptcha is installed.
 @option options [String]  :pageurl The URL of the page where the recaptcha is encountered.

 @return [TwoCaptcha::Captcha] The solution of the given captcha.
Solve reCAPTCHA v2 .