用 Puppeteer 下载网页 pdf 版本

    mkdir play_puppeteer && cd $_
    yarn add puppeteer
    emacs main.js
    node main.js

main.js

    const puppeteer = require('puppeteer');

    (async () => {
      const browser = await puppeteer.launch();
      const page = await browser.newPage();
      await page.goto('https://www.baidu.com/', {
        waitUntil: 'networkidle2',
      });
      await page.pdf({ path: 'baidu.pdf', format: 'a4' });

      await browser.close();
    })();
欢迎通过「邮件」或者点击「这里」告诉我你的想法
Welcome to tell me your thoughts via "email" or click "here"