1

THIS IS NOT ABOUT HOW TO RETRIEVE TEXT FROM CATPCHA

Basically my problem is that after i extract text from captcha and enter it in the provided box, and simulate the 'return' key using element.send_keys(Keys.RETURN), an alert box comes up saying captcha was wrong and a new captcha comes up, though i can verify that text matches the captcha. I've also tried using the 'click' action on the submit button but no help.

An interesting thing i noticed was that if I automate the process upto entering captcha text and then press enter/click submit, everything works fine. So i think there is some problem in my way of simulating return/click through selenium. Any idea what can the problem be.

Just for the record I'm using tesseract OCR with pytesseract wrapper for python to decode captchas and I AM getting CORRECT text outputs in 90%+ cases, so its not just because of wrong text. I've also checked to remove any leading or trailing spaces using strip() method.

2

1 Answer 1

2

Your script is correct, you just need to insert a time.sleep(5) before submitting the final form: https://gist.github.com/pratyushmittal/68f67c20e4fb6f0cd072/5b9bec7de5e8fadd65a22e729015fc89de6dfca8

Selenium submits the captcha form as soon as the page finishes loading. In the current case, the website marks that as a robotic activity and displays the error.

Alternatively, you can also use RoboBrowser to go without Selenium (though this too will require a sleep): https://gist.github.com/pratyushmittal/68f67c20e4fb6f0cd072/c65742ce78631058378c91ee89d0508874ea7ace

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.