Tianhe Gao

用 Puppeteer 下载网页 pdf 版本

1    mkdir play_puppeteer && cd $_
2    yarn add puppeteer
3    emacs main.js
4    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();
    })();

No notes link to this note

Welcome to tell me your thoughts via "email"
UP