Class: Clients::Recaptcha::Solver
- Inherits:
-
Object
- Object
- Clients::Recaptcha::Solver
- Defined in:
- lib/clients/recaptcha/solver.rb
Constant Summary collapse
- INIT_URL =
Addressable::URI.parse("http://2captcha.com/in.php").freeze
- SOLVE_STATUS_URL =
Addressable::URI.parse("http://2captcha.com/res.php").freeze
Instance Attribute Summary collapse
-
#captcha_key ⇒ Object
readonly
Returns the value of attribute captcha_key.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#sleep_duration ⇒ Object
readonly
Returns the value of attribute sleep_duration.
Instance Method Summary collapse
-
#initialize(client, captcha_key: ENV["CAPTCHA_SOLVER_KEY"], sleep_duration: 5) ⇒ Solver
constructor
A new instance of Solver.
- #solve(banned_url, response) ⇒ Object
Constructor Details
#initialize(client, captcha_key: ENV["CAPTCHA_SOLVER_KEY"], sleep_duration: 5) ⇒ Solver
Returns a new instance of Solver.
12 13 14 15 16 |
# File 'lib/clients/recaptcha/solver.rb', line 12 def initialize(client, captcha_key: ENV["CAPTCHA_SOLVER_KEY"], sleep_duration: 5) @client = client @captcha_key = captcha_key @sleep_duration = sleep_duration end |
Instance Attribute Details
#captcha_key ⇒ Object (readonly)
Returns the value of attribute captcha_key.
10 11 12 |
# File 'lib/clients/recaptcha/solver.rb', line 10 def captcha_key @captcha_key end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
10 11 12 |
# File 'lib/clients/recaptcha/solver.rb', line 10 def client @client end |
#sleep_duration ⇒ Object (readonly)
Returns the value of attribute sleep_duration.
10 11 12 |
# File 'lib/clients/recaptcha/solver.rb', line 10 def sleep_duration @sleep_duration end |
Instance Method Details
#solve(banned_url, response) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/clients/recaptcha/solver.rb', line 18 def solve(banned_url, response) site_key = find_site_key(response) solved_path = find_solve_url(response) id = init_solver banned_url, site_key token = get_solution id solved_response = solve_captcha banned_url, solved_path, token solved_response. end |