我正在使用 Puppeteer 解析一个网页,但找不到确切的答案来回答我的问题。
我试图将一个函数作为参数传递给 page.evaluate()
,传递对象可以,但似乎无法传递函数。下面是一个人为制造的例子:
const obj = {
thing: 'thing1',
};
const myfunction = () => {
return `great ${stuff}`;
};
await page.evaluate((obj, function)=>{
const thing = myfunction;
},(obj, function));
在Puppeteer的page.evaluate()中,是否可以将函数作为参数传递?
"Uncaught (in promise) Error: this._pageBindings.get(...) is not a function", source: (2)
的错误。 - Falko