📜  puppeteer 事件元素更改 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:29.560000             🧑  作者: Mango

代码示例1
const puppeteer = require('puppeteer');

(async() => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.exposeFunction('onCustomEvent', text => console.log(text));
  await page.goto('https://www.time.ir', {waitUntil: 'networkidle0'});
  await page.evaluate(() => {
    $('#digitalClock').bind("DOMSubtreeModified", function(e) {
      window.onCustomEvent(e.currentTarget.textContent.trim());
    });
  });
})();