对不起,我犯了一个错误。Page.screenshot()确实没有clip参数。我混淆了Puppeteer和Playwright的API。

在Puppeteer中,您需要使用以下方法来截取页面的特定区域:

await page.screenshot({
  path: 'example.png',
  clip: { x: 0, y: 0, width: 100, height: 100 }
});

对于Playwright,您可以使用以下方法:

await page.screenshot({
  path: 'example.png',
  clip: { x: 0, y: 0, width: 100, height: 100 }
});

感谢您让我注意到我的错误。

Puppeteer和Playwright截取页面特定区域的正确方法

原文地址: https://www.cveoy.top/t/topic/oNi2 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录