-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscreenshot.js
More file actions
32 lines (29 loc) · 843 Bytes
/
screenshot.js
File metadata and controls
32 lines (29 loc) · 843 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
32
const puppeteer = require("puppeteer-extra");
puppeteer.use(require("puppeteer-extra-plugin-stealth")());
const pageCmd = require('./pageCmd.js');
//console.log(process.argv);
const myArgs = process.argv.slice(2);
//console.log('myArgs: ', myArgs);
const url = myArgs[0];
//console.log(url);
if(undefined === url || url.length < 1 ) {
throw new Error("Url is empty");
}
let filename = myArgs[1];
if(undefined === filename || filename.length < 1 ) {
filename = url.toLowerCase().replace(/[^a-z0-9]+/g, '-') + '.png';
}
// START
(async () => {
try {
let command_obj = [
{cmd: 'goto', val: url},
{cmd: 'screenshot', val: filename}
];
//console.log(command_obj);
await pageCmd(command_obj);
} catch (err) {
console.error(err);
process.exit(1);
}
})();