首先安装
cnpm install --save-dev puppeteer
截图功能
const puppeteer = require('puppeteer'); const {screenShot} = require('./default/config.js'); (async()=>{ const browser = await puppeteer.launch(); const page = await browser.newPage();//打开一个页 await page.goto('https://www.baidu.com');//跳转到这个页 console.log("screenShot"+screenShot) await page.screenshot({ path:`${screenShot}/${Date.now()}.png` }) })();//自动执行的意思
创建 .gitignore文件的方法 进入文件夹右键 git Bash touch .gitignore