Hack Forums
Using DeathByCaptcha API on Ruby? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Coders Lounge (https://hackforums.net/forumdisplay.php?fid=5)
+---- Thread: Using DeathByCaptcha API on Ruby? (/showthread.php?tid=4385171)



Using DeathByCaptcha API on Ruby? - rrdein - Aug 8, 2014

Tried to post this on BHW but that gay ass site has so many restrictions (telling me there is a URL in the code below; not allowed for new users) that I decided to come and try my luck here. I'm trying to use the DBC API with Ruby and I need a little bit of help. Any help is appreciated.

---------------------

This is my code:

Code
@driver.get("MyURL")
    captchaUrl = @driver.find_element(:id, "recaptcha_challenge_image").attribute("src")
    client = DeathByCaptcha.http_client('username', 'password')
    response = client.decode captchaUrl
    dbcfields = response.split('"')
    puts dbcfields[9]

I get an error on split. I have been trying this different ways (most of which do not use split), but between a poor knowledge of Ruby and some poor documentation for DBC API, I cannot figure this out.

The line, "puts response" outputs results, but the output looks like this:

Code
{"status"=>0, "captcha"=>296866378, "is_correct"=>true, "text"=>"year yestrease"}

It is correctly solving the Captcha. However, I cannot extract the response field from the string. I tried using split but I got an "undefined method" for split. I am guessing this means that response is not an actual string.

DBC has several methods for their API, and any solution using the API is acceptable to me as long as I can understand it.

Thank you in advance.