Puppeteer 中的选择性渲染
Selective Rendering in Puppeteer
是否可以在 puppeteer 中只渲染一个 div(或使用任何选择器)?
示例:我的页面上有很多信息,我只想截图其中的一部分,一个div,目前我使用截图api的clip
选项
但是有没有一种方法可以通过指定选择器来截屏?
有很多很酷的例子ElementHandle.screenshots tests,例如:
await page.setViewport({width: 500, height: 500});
await page.goto(server.PREFIX + '/grid.html');
await page.evaluate(() => window.scrollBy(50, 100));
const elementHandle = await page.$('.box:nth-of-type(3)');
const screenshot = await elementHandle.screenshot();
是否可以在 puppeteer 中只渲染一个 div(或使用任何选择器)?
示例:我的页面上有很多信息,我只想截图其中的一部分,一个div,目前我使用截图api的clip
选项
但是有没有一种方法可以通过指定选择器来截屏?
有很多很酷的例子ElementHandle.screenshots tests,例如:
await page.setViewport({width: 500, height: 500});
await page.goto(server.PREFIX + '/grid.html');
await page.evaluate(() => window.scrollBy(50, 100));
const elementHandle = await page.$('.box:nth-of-type(3)');
const screenshot = await elementHandle.screenshot();