Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

172
Views
Tener un error de Javascript: "Invocación ilegal" al enviar un script JS usando Python Selenium Webdriver

Estoy tratando de omitir el captcha (resolución automática) al iniciar sesión en un sitio web. Pero cuando ejecuto un script JS después de recibir el código de respuesta de 2Captcha, recibí un error de javascript: Invocación ilegal . Aquí está mi código:

 u1 = f"https://2captcha.com/in.php?key={API_KEY}&method=userrecaptcha&googlekey={data_sitekey}&pageurl={page_url}&json=1&invisible=1" r1 = requests.get(u1) print(r1.json()) rid = r1.json().get("request") u2 = f"https://2captcha.com/res.php?key={API_KEY}&action=get&id={int(rid)}&json=1" time.sleep(5) while True: r2 = requests.get(u2) print(r2.json()) if r2.json().get("status") == 1: form_token = r2.json().get("request") break time.sleep(5) write_tokon_js = f'document.getElementById("g-recaptcha-response").innerHTML="{form_token}";' submit_js = "document.createElement('form').submit.call(document.getElementsByClassName('button')[0]);" driver.execute_script(write_tokon_js) time.sleep(3) driver.execute_script(submit_js) time.sleep(10)

Al principio, traté de enviar el formulario usando document.getElementsByClassName('button')[0].submit() pero después de un tiempo de investigar en google y stackoverflow , me di cuenta de que un sitio web que estoy tratando de automatizar tiene tantas clases de botones y no funcionará, así que cambié al código anterior.

Creo que hay algo mal en mi submit_js pero no sé exactamente por qué, no estoy familiarizado con Javascript. Por favor ayúdame a arreglarlo.

EDITAR 1 Aquí está el código HTML de un botón que estoy tratando de enviar:

 <p class="submit"> <input type="hidden" name="action" value="register_handler"> <input type="hidden" name="jnews_nonce" value="36b5269a22"> <input type="submit" name="jeg_login_button" class="button" value="Đăng ký" data-process="Processing . . ." data-string="Đăng ký"> </p>

Creo que el problema es que esto es solo un botón, no un formulario, por eso no puedo enviarlo. Pero no sé cómo enviar (traté de hacer clic en el botón usando Webdriver después de ingresar el código recibido de 2captcha dentro de "g-recaptcha-response" pero siempre devuelve Captcha no válido, parece que la única forma de continuar es enviar usando Scripts JS pero todavía no sé cómo)

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!