PuppeteerSharp中是否有对应NewPageAsync()的remove page方法?

Is there a remove page method corresponding to NewPageAsync() in PuppeteerSharp?

我将浏览器对象保持为单例,并希望为可能有数千个 url 调用 NewPageAsync()。有没有办法在使用后清理页面?

您可以使用 CloseAsync 关闭页面:

var page = browser.NewPageAsync();
////
await page.CloseAsync();

using 块也将关闭页面:

using (var page = await new browser.PageAsync())
{
///
}

Puppeteer-Sharp v2.0.3+还支持await using

await using (var page = await new browser.PageAsync())
{
 ///
}