如何在page.evaluate中使用另一个模块?

时间:2018-11-26 20:44:43

标签: javascript node.js google-chrome asynchronous puppeteer

我需要在浏览器上下文之外调用外部api /模块,然后在if语句之后切换回puppeteer上下文。 感谢您的协助。

const puppeteer =require('puppeteer');

(async () => {
const browser = await puppeteer.launch({headless: false}); 
const page = await browser.newPage();
await page.goto('https://example.com');



await page.evaluate(() => {




var x = 
document.documentElement.outerHTML

var  s = x.includes('Example')


if (s = true) {
// **Must simply use other module / {api} and switch back to puppeteer
 context** 
}


});



})();

0 个答案:

没有答案