ARU*_*SON 2 pdf node.js npm puppeteer
我尝试使用木偶师,
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('https://10.1.40.117/print/d37a2017-4bc4-46fb-9a8a-7ddc31e65a33', {waitUntil: 'networkidle2'});
await page.pdf({path: 'hn.pdf', format: 'A4'});
await browser.close();
})();
Run Code Online (Sandbox Code Playgroud)
出现以下错误,
(node:16064) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: net::ERR_CERT_AUTHORITY_INVALID at https://10.1.40.117/print/d37a2017-4bc4-46fb-9a8a-7ddc31e65a33
(node:16064) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Run Code Online (Sandbox Code Playgroud)
对此有什么帮助吗?
ignoreHTTPSErrors: true
在启动浏览器实例时尝试。当您在本地使用自签名证书时会发生这种情况。
解决方案:
const browser = await puppeteer.launch({ignoreHTTPSErrors: true});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
5265 次 |
最近记录: |