Created
March 23, 2019 16:10
-
-
Save vsemozhetbyt/bff88b6b15e5bb2571ee8e8d9001a84a to your computer and use it in GitHub Desktop.
Revisions
-
vsemozhetbyt created this gist
Mar 23, 2019 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ '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); } })();