-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
41 lines (36 loc) · 1.13 KB
/
app.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
const { Cluster } = require('puppeteer-cluster');
(async () => {
//Your array of URLs define
const requests = [
'https://www.worldpranichealing.com/en/wesak/benefits-of-meditating-during-wesak/',
'https://www.worldpranichealing.com/en/wesak/a-ceremony-in-the-himalaya/',
];
// Your element name you want to find in dom element.
const element = '.rtpanel section ul';
const cluster = await Cluster.launch({
concurrency: Cluster.CONCURRENCY_CONTEXT,
maxConcurrency: 1,
});
await cluster.task(async ({ page, data }) => {
let { url } = data;
await page
.goto(url, {
timeout: 120000,
waitUntil: 'networkidle2',
})
.catch((e) => {
console.error(e.message, `This was a failure.Url is ${url}`);
});
//Here is main check happened
(await page.$(element)) !== null
? console.log(`Your Element ('${element}') is not found in this ${url}`)
: console.log(`Your Element ('${element}') is found in this ${url}`);
});
requests.forEach((url) => {
cluster.queue({
url: url,
});
});
await cluster.idle();
await cluster.close();
})();