Tag: puppeteer

将jquery注入puppeteer页面

我正在尝试将jquery注入我的puppeteer页面,因为document.querySelector不会为我剪切它: async function inject_jquery(page){ await page.evaluate(() => { var jq = document.createElement(“script”) jq.src = “https://code.jquery.com/jquery-3.2.1.min.js” document.querySelector(“head”).appendChild(jq) }) const watchDog = page.waitForFunction(‘window.jQuery !== undefined’); await watchDog; } 结果是它大部分时间超时。 有没有人有办法解决吗?