-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
31 lines (21 loc) · 703 Bytes
/
index.js
File metadata and controls
31 lines (21 loc) · 703 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
28
29
30
31
// BUILT IN Node.js modules.
const path = require("path");
const args = process.argv;
// Third party node modules (gotten through npm).
const puppeteer = require("puppeteer");
// custom modules
const screenshot = require('./screenshot');
// Our main function (taking screenshot)
async function main() {
const browser = await puppeteer.launch({
args: ["--no-sandbox", "--disable-setuid-sandbox"]
});
const page = await browser.newPage();
await page.goto(args[2]);
const buffer = await page.screenshot();
await browser.close();
const imageLocation = path.join(__dirname, "screenshot.jpg");
await screenshot.write(imageLocation, buffer);
return Promise.resolve();
}
main();