-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
34 lines (28 loc) · 951 Bytes
/
index.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
const { plugin } = require("puppeteer-with-fingerprints");
const { Cluster } = require('puppeteer-cluster');
(async () => {
// Get a fingerprint from the server:
const fingerprint = await plugin.fetch('', {
tags: ['Microsoft Windows', 'Chrome'],
});
// Apply fingerprint:
plugin.useFingerprint(fingerprint);
const cluster = await Cluster.launch({
puppeteer: plugin,
concurrency: Cluster.CONCURRENCY_CONTEXT,
maxConcurrency: 2,
puppeteerOptions: {
headless: false,
},
});
await cluster.task(async ({ page, data: url }) => {
await page.goto(url);
await page.screenshot({ path: `${ await page.title() }.png`});
// Store screenshot, do something else
});
cluster.queue('http://www.google.com/');
cluster.queue('http://www.wikipedia.org/');
// many more pages
await cluster.idle();
await cluster.close();
})();