This repository was archived by the owner on Aug 31, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathtest-puppet.js
More file actions
49 lines (47 loc) · 1.5 KB
/
test-puppet.js
File metadata and controls
49 lines (47 loc) · 1.5 KB
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
44
45
46
47
48
49
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.setExtraHTTPHeaders({ Referer: 'https://sparktoro.com/' })
await page.goto('https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0597477');
await page.waitForSelector('.kb-permalink');
const availablePatchLinks = await page.evaluate(() => {
const links = Array.from(document.querySelectorAll('li > a'))
console.log(links);
var patchLinks = links.filter(link => {
if (link.title.indexOf('Patch') >= 0) {
return true;
}
})
return patchLinks.map(link => {
return {
"href": link.href,
"title": link.title
}
})
})
console.log(availablePatchLinks);
/*let patches = {}
availablePatchLinks.forEach(async (patch) => {
patches[patch.title] = [];
const browser2 = await puppeteer.launch();
const page2 = await browser2.newPage();
await page2.setExtraHTTPHeaders({ Referer: 'https://sparktoro.com/' })
await page2.goto(patch.href);
await page2.waitForSelector('.kb-permalink');
await page2.evaluate(() => {
const links = Array.from(document.querySelectorAll('li > a'))
console.log(links);
patches[patch.title] = links.map(link => {
return {
"href": link.href,
"title": link.title
}
})
})
console.log(availablePatchLinks);
})
*/
await browser.close();
//console.log(patches);
})();