Well that quite easy, let's learn to solve captcha with selenium webdriver using python.
here's how you can automate captcha with selenium python:
How to solve captcha with selenium python
- Create your bot,
- Come into the captcha solving section
- Register or sign in at 2captcha.com
- Get some credits
- Install TwoCpatcha:
pip install TwoCaptcha
- Try below codes
Try this code in your web document:
textarea = driver.find_element_by_id('g-recaptcha-response')
solution = solve()
code = solution['code']
driver.execute_script(f"var ele=arguments[0]; ele.innerHTML = '{code}';", textarea)
time.sleep(1) # waiting is mandatory
textarea = driver.find_element_by_xpath('//*[@id="login-btn"]/button').click()
Here's the solve()
function:
def solve():
import sys
from twocaptcha import TwoCaptcha
result = None
sitekey = '<your_site_key_from_two_captcha>'
api_key = '<your_api_key_from_two_captcha>'
solver = TwoCaptcha(api_key)
try:
result = solver.recaptcha(
sitekey=sitekey,
url='https://www.deezer.com/en/login'
)
except Exception as e:
sys.exit(e)
return result
And for the site key, here's how you can get the sitekey to solve the captcha.
Or Hire Me to do it.
Have a good day, Pythoning!
Top comments (0)