(async() => { const browser = await puppeteer.launch({ headless: true, args: ["--no-sandbox", "--single-process"], }); const page = await browser.newPage(); await page.setViewport({ width: 1920, height: 1080 }); // ‘networkidle2’ means that there are no more than 2 active requests open. // This is a good setting because for some websites (e.g. websites using websockets) there will always be connections open await page.goto(url, { waitUntil: 'networkidle2', timeout: 1000 * 60 * 5, // 毫秒 超时参数需要加上,有时候网络不好,会导致等着 }); await page.screenshot({path: './data/website.png', type: 'png'}); page.close(); browser.close(); })();