我正在使用Puppeteer和Node.js创建屏幕截图生成器。它对于普通网页运行良好,但对于PDF页面,每次运行都会出现相同的错误。
这是代码(来自https://github.com/GoogleChrome/puppeteer的第一个示例):
我得到的错误
这是代码(来自https://github.com/GoogleChrome/puppeteer的第一个示例):
const puppeteer = require('puppeteer');
(async () => {
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf');
await page.screenshot({ path: 'example.png' });
await browser.close();
} catch (err) {
console.log(err);
}
})();
我得到的错误
Error: net::ERR_ABORTED at https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf
at navigate (C:\MEAN\puppeteer-demo\node_modules\puppeteer\lib\FrameManager.js:121:37)
at process._tickCallback (internal/process/next_tick.js:68:7)
-- ASYNC --
at Frame.<anonymous> (C:\MEAN\puppeteer-demo\node_modules\puppeteer\lib\helper.js:110:27)
at Page.goto (C:\MEAN\puppeteer-demo\node_modules\puppeteer\lib\Page.js:629:49)
at Page.<anonymous> (C:\MEAN\puppeteer-demo\node_modules\puppeteer\lib\helper.js:111:23)
at C:\MEAN\puppeteer-demo\index.js:7:20
at process._tickCallback (internal/process/next_tick.js:68:7)
非常感谢您的帮助。我也愿意接受任何其他可能的解决方案。