gpt4 book ai didi

c# - 如何等待 PuppeteerSharp 中的异步函数评估

转载 作者:行者123 更新时间:2023-11-30 20:16:04 24 4
gpt4 key购买 nike

在 Puppeteer 中,您可以评估异步函数:

await page.evaluate(async () => {
// await some promise
});

PuppeteerSharp 中是否有等效项?使用 EvaluateFunctionAsync,任务在 promise 解决之前完成:

await page.EvaluateFunctionAsync(@"async () => {
// await some promise
}");

最佳答案

这是正确的方法,例如:

var six = await page.EvaluateFunctionAsync<int>("async () => await Promise.resolve(6)");

关于c# - 如何等待 PuppeteerSharp 中的异步函数评估,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51093017/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com