-
Notifications
You must be signed in to change notification settings - Fork 19
/
puppeteer.js
50 lines (48 loc) · 1.36 KB
/
puppeteer.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
const puppeteer = require('puppeteer')
const url = process.argv[2]
const destination = process.argv[3]
if (!url) {
throw new Error('Please provide a URL as the first argument')
}
if (!destination) {
throw new Error('Please provide a filenamee destination as the second argument')
}
const h = 1080
const w = 1500;
(async () => {
const browser = await puppeteer.launch({
args: [
'--disable-dev-shm-usage',
'--disable-session-crashed-bubble',
'--disable-infobars',
'--disable-setuid-sandbox',
'--disable-gpu',
'--disable-font-subpixel-positioning',
'--enable-automation',
'--enable-font-antialiasing',
'--font-render-hinting=none',
'--force-color-profile=srgb',
'--hide-scrollbars',
'--ignore-certificate-errors',
'--kiosk',
'--noerrdialogs',
'--no-default-browser-check',
'--no-sandbox',
'--start-fullscreen',
'--start-maximized',
'--useAutomationExtension',
'--user-data-dir=./.chrome',
'--window-size=1500,1080'
],
ignoreDefaultArgs: ['--enable-automation'],
headless: 'new'
})
const page = await browser.newPage()
await page.setViewport({ width: w, height: h })
await page.goto(url, { waitUntil: 'networkidle0' })
// await page.waitForTimeout(5000)
await page.screenshot({
path: destination
})
await browser.close()
})()