Created
March 23, 2019 16:10
-
-
Save vsemozhetbyt/bff88b6b15e5bb2571ee8e8d9001a84a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const puppeteer = require('puppeteer'); | |
(async function main() { | |
try { | |
const browser = await puppeteer.launch(); | |
const [page] = await browser.pages(); | |
await page.goto('https://example.org/'); | |
const data = await page.evaluate(() => { | |
const hrefs = Array.from( | |
document.querySelectorAll('a[href]'), | |
({ href }) => href | |
); | |
return Array.from(new Set(hrefs)); | |
}); | |
console.log(data); | |
await browser.close(); | |
} catch (err) { | |
console.error(err); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment