I'm writing an application, in which the user needs to solve a recaptcha image outside of a browser, basically they would see the image from a page like this http://www.google.com/recaptcha/api/noscript?k=6Lf5YAcAAAAAAILdm73fp007vvmaaDpFb6A5HLJP, submit the solution and the program would do the rest.
I am using mechanize to automate interaction with that page and for some reason it always gives me a 500 response code. I've tried setting the useragent with mechanize to no avail. I'm sort of at a loss about what I should do, because I've inspected (with wireshark) the packets that mechanize is sending/recieving and compared them to the ones when I use chrome to get the code, and they look nearly the same! (It's a post message and they have the same params, etc and are posting to the same place)
I'm pretty sure it's something obvious, but still I've been battling it for hours and would appreciate some help.
EDIT for code
agent = Mechanize.new do |i|
i.user_agent_alias = 'Mac Safari'
i.log = Logger.new 'captcha.log'
end
agent.get(captcha_url) do |google_page| # captcha_url is a url like the one above
form = google_page.forms.first
form.recaptcha_response_field = captcha_text # captcha_text is user-input
form.
form.submit # this line is where the error is
end