0
圖片- 2 -和一些款式- 1 -我不使用木偶時加載page.pdf.
即使我設置了page.waitForNavigation
。
如果我用的page.screenshot
代替page.pdf
它的工作原理相同的代碼!
如何配置puppeteer以獲取完整圖像和樣式的pdf頁面?
- 節點V8.5.0
- 木偶0.10.2(最新)
代碼:
const puppeteer = require('puppeteer');
const link = 'https://chrome.google.com/webstore/category/extensions?hl=pt-BR';
(async() => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(link);
await page.waitForNavigation({timeout: 120000, waitUntil: 'networkidle', networkIdleTimeout: 3000});
await page.pdf({path: 'page.pdf'});
// if I remove page.pdf and change to the line below it works!
//await page.screenshot({fullPage: true, path: 'page.png'});
browser.close();
})()