forked from touhidrahman/eyecatching
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpuppeteer.js
More file actions
27 lines (20 loc) · 795 Bytes
/
puppeteer.js
File metadata and controls
27 lines (20 loc) · 795 Bytes
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
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const url = process.argv[2];
const width = parseInt(process.argv[3]);
const height = parseInt(process.argv[4]);
await page.goto(url);
// Get the "viewport" of the page, as reported by the page.
const dimensions = await page.evaluate(() => {
return {
width: document.documentElement.clientWidth,
height: document.documentElement.clientHeight,
deviceScaleFactor: window.devicePixelRatio
};
});
await page.setViewport({width: width, height: dimensions.height})
await page.screenshot({path: 'screenshot.png', fullPage: true});
await browser.close();
})();