PythonReactor
PythonReactor

Reputation: 482

Submitting reCAPTCHA v2 with selenium and python - no form submit button

I recently signed up with anti-captcha and have been testing with the https://github.com/ad-m/python-anticaptcha/blob/master/examples/recaptcha_selenium.py script.

I cannot get past a reCAPTCHA that has no submit button (hidden or visible) nor a clear way to submit for verification. I've used the anti-captcha Firefox plugin, so I know it can be passed. But I am stuck at the point of doing this manually myself.

I thought this was going to be a helpful answer, but it doesn't go into depth. I am able to get the job.get_solution_response() token and enter it into the required textfield, but I cannot submit the "form."

Does anyone have success with this? I am also looking to do this in a headless version of the browser. Would a solution be different based on headless vs non-headless?

BTW, realtor(dot)com is the website I am having trouble with. If I am not allowed to post this site, please let me know so I can remove it.

Upvotes: 3

Views: 2924

Answers (2)

PythonReactor
PythonReactor

Reputation: 482

I went back into the source code of the site and found they are using a function as a callback for verification...

I saw that they are using a function called solvedCaptcha and injecting a variable name payload. So here is how I solved it:

NOTE: Make sure the driver is currently on the reCAPTCHA page.

driver.execute_async_script("var payload = '<enter the job.get_solution_response() here>'; solvedCaptcha(payload);")

This async script then calls the page's verification and it reloads the blocked window.

NOTE: This CAPTCHA did not have a submit button and was not placed in a form. So using .submit() on an item within the driver would not work.

Upvotes: 2

Hezi Israeli
Hezi Israeli

Reputation: 439

try to sendKeys of \n or Keys.Enter to the textfield. This was my solution in my projects. Also this is generic one

Upvotes: 0

Related Questions