maxrosecollins
Newbie
- Sep 11, 2013
- 7
- 1
Hi,
I am building a program to check for keyword positions.
I am writing this in Ruby and using Mechanize to visit pages/submit forms/find the content i need, etc
Everything is working correctly except when I make too many requests too quickly, then Google presents my app with a captcha to solve.
I have run into a problem with Googles captchas. I can send them to DeathByCaptcha and get the response okay.
The issue is Google gives you a URL of the captcha, but if you reload this URL then the captcha changes to a different image.
So my solution is to save the image and then send this to DeathByCaptcha as sending the URL obviously won't work.
The bit I am stuck with is this
In making a second request to download the image the Captcha changes so the response I get back from DeathByCaptcha whilst correct doesn't work when I enter this on the Google form and submit it.
Does anyone know how to do this in one request? or how I can overcome this issue with a different method? been trying to figure it out for a week now with no success. So thought I would ask here.
I would be happy to provide the full code if someone can help
Below is an example of what I am doing
I am building a program to check for keyword positions.
I am writing this in Ruby and using Mechanize to visit pages/submit forms/find the content i need, etc
Everything is working correctly except when I make too many requests too quickly, then Google presents my app with a captcha to solve.
I have run into a problem with Googles captchas. I can send them to DeathByCaptcha and get the response okay.
The issue is Google gives you a URL of the captcha, but if you reload this URL then the captcha changes to a different image.
So my solution is to save the image and then send this to DeathByCaptcha as sending the URL obviously won't work.
The bit I am stuck with is this
- I make a request to Google and get the page which displays the Captcha and form to solve it.
- I then have to make another request to download the image.
In making a second request to download the image the Captcha changes so the response I get back from DeathByCaptcha whilst correct doesn't work when I enter this on the Google form and submit it.
Does anyone know how to do this in one request? or how I can overcome this issue with a different method? been trying to figure it out for a week now with no success. So thought I would ask here.
I would be happy to provide the full code if someone can help
Below is an example of what I am doing
Code:
[COLOR=#00008B]begin[/COLOR]
a.get('URL to google page that displays Captcha[COLOR=#800000]'[/COLOR])
[COLOR=#00008B]rescue[/COLOR] [COLOR=#2B91AF]Mechanize[/COLOR]::[COLOR=#2B91AF]ResponseCodeError[/COLOR] => e
imageurl = e.page.search([COLOR=#800000]'img'[/COLOR])[[COLOR=#800000]0[/COLOR]][[COLOR=#800000]'src'[/COLOR]] # find captcha url on page
a.get(imageurl).save [COLOR=#800000]"path/to/folder/image_name.jpg" # save captcha image
[/COLOR] # send image to deathbycaptcha
# get response
# submit google form with response
[COLOR=#00008B]end[/COLOR]