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

112
Views
Función de inyección con Titiritero

Estoy tratando de inyectar esta función en la página web con Puppeteer para obtener los oyentes de eventos del sitio web.

mi código es:

 Array.from(document.querySelectorAll('*')) .reduce(function(pre, dom){ var evtObj = getEventListeners(dom) Object.keys(evtObj).forEach(function (evt) { if (typeof pre[evt] === 'undefined') { pre[evt] = 0 } pre[evt] += evtObj[evt].length }) return pre }, {})

He intentado ejecutar el código a continuación.

 'use strict'; const puppeteer = require('puppeteer'); (async () => { const browser = await puppeteer.launch({ headless: false }); const page = await browser.newPage(); await page.goto('https://google.com') var FunctionToInject = function(input){ Array.from(document.querySelectorAll('*')) .reduce(function(pre, dom){ var evtObj = getEventListeners(dom) Object.keys(evtObj).forEach(function (evt) { if (typeof pre[evt] === 'undefined') { pre[evt] = 0 } pre[evt] += evtObj[evt].length }) return pre }, {}) } await page.exposeFunction('functionToInject', functionToInject); var data = await page.evaluate(async function(){ return await FunctionToInject(); }); console.log(data); await browser.close(); })();

Recibo UnhandledPromiseRejectionWarning: Error: Error de evaluación: ReferenceError: el documento no está definido . ¿Cómo puedo resolver este problema?

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!