Python Javascript selenium captchasolving

  browser, captcha, javascript, python, selenium

i managed to use selenium in python and then i sued to driver.execute_script() method to execute javascript in the dev console. I made a little script that login into a discordaccount by the accounttoken and this script seems to work completly fine. however after it solved the captcha and added to value of it into the site it not continue with the script because i will need to add a other pythoncode that do something like press a button etc to do the next stuff but on the site i try to use the script on is no button like this so im not sure what to do now. Maybe the following code explain more what i wanted to do:

try:
  WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.NAME, "h-captcha-response")))
  solver =  captchatools.captcha_harvesters(
  solving_site="capmonster", api_key="capmonster.cloud apikey was here", sitekey="f5561ba9-8f1e-40ca-9b5b-a0b3f719ef34", captcha_url="https://discord.com/login"
  )
  captcha_answer = solver.get_token()
  print(captcha_answer)
  driver.execute_script('document.getElementsByName("h-captcha-response").innerHTML = "{}";'.format(captcha_answer))

except Exception:
  print("Logged in without a captcha needed")
  raise Exception

Source: Python Questions

LEAVE A COMMENT