-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathpuppeteer-es5.js
More file actions
24 lines (22 loc) · 840 Bytes
/
puppeteer-es5.js
File metadata and controls
24 lines (22 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const puppeteer = require('puppeteer');
const path = require('path');
const fs = require('fs');
(async() => {
try {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('https://www.polymer-project.org/2.0/docs/upgrade')
await page.addScriptTag({
path: path.join(__dirname, 'node_modules/query-selector-shadow-dom/dist/querySelectorShadowDom.js')
});
// execute standard javascript in the context of the page.
const downloads = await page.evaluate(() => {
const anchors = Array.from(querySelectorShadowDom.querySelectorAllDeep('a'))
return anchors.map(anchor => anchor.href)
})
console.log(downloads)
await browser.close()
} catch (e) {
console.error(e);
}
})()