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

176
Views
ejecutando el código javascript pensó en el protocolo de herramientas de desarrollo de Chrome

Estoy tratando de ejecutar algún código javascript a través de la biblioteca CDTP y PyChromeDevTools. El siguiente código funciona:

desde la terminal:

 /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222

 import PyChromeDevTools chrome.Network.enable() chrome.Page.enable() script="t='hi,';c='this code works on the same line';console.log(t,c)" chrome.Runtime.evaluate(expression=script)

Tengo algunos problemas cuando necesito inyectar un código js complejo que no está en la misma línea, por ejemplo, funciona con solicitudes de javascript, etc.

 script="t='hi,'; c='this code works not on the same line don't work '; console.log(t,c)" chrome.Runtime.evaluate(expression=script)

¿Es posible que el archivo JavaScript sea igual al tiempo de ejecución para evaluar? como esto:

 chrome.Runtime.evaluate(expression=file.js)

documentación del CDTP

https://chromedevtools.github.io/devtools-protocol/

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Simplemente debe cargar un código js de un archivo en la variable str

 def load_text(filename, mode='r', encoding='utf-8'): with open(filename, mode, encoding=encoding) as f: txt = f.read() return txt file_js = load_text('file.js') chrome.Runtime.evaluate(expression=file_js)
about 4 years ago · Juan Pablo Isaza Report
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!