-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
example.ts
30 lines (25 loc) · 1.01 KB
/
example.ts
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
import { KnownDevices } from 'puppeteer';
import { CollectorOptions, collect } from './src';
import { join } from 'path';
(async () => {
const URL = process.argv.length > 2 ? process.argv[2] : 'example.com';
const EMULATE_DEVICE = 'iPhone 13 Mini';
const config: CollectorOptions = {
numPages: 1,
headless: false,
emulateDevice: KnownDevices[EMULATE_DEVICE],
// Uncomment to run with desktop/laptop browser
// emulateDevice: {
// viewport: {height: 1440, width: 800},
// userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36"
// },
outDir: join(__dirname, 'demo-dir')
};
console.log(`Beginning scan of ${URL}`);
const result = await collect(`http://${URL}`, config);
if (result.status === 'success') {
console.log(`Scan successful: ${config.outDir}`);
} else {
console.error(`Scan failed: ${result.page_response}`);
}
})();