-
Notifications
You must be signed in to change notification settings - Fork 0
/
screenshot.js
43 lines (36 loc) · 1.02 KB
/
screenshot.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
const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
puppeteer.use(StealthPlugin());
const url = process.argv[2];
const timeout = 5000;
(async () => {
let browser;
try {
browser = await puppeteer.launch({
headless: false, // corrected to boolean
executablePath: 'Your_PATH',
userDataDir: 'Your_PATH',
});
const page = await browser.newPage();
await page.setViewport({
width: 1200,
height: 1200,
deviceScaleFactor: 1,
});
await page.goto(url, {
waitUntil: "domcontentloaded",
timeout: timeout,
});
await page.waitForTimeout(timeout);
await page.screenshot({
path: "screenshot.jpg",
fullPage: true,
});
} catch (error) {
console.error('Error occurred:', error);
} finally {
if (browser) {
await browser.close();
}
}
})();