Skip to content

Instantly share code, notes, and snippets.

@vsemozhetbyt
Created March 23, 2019 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vsemozhetbyt/bff88b6b15e5bb2571ee8e8d9001a84a to your computer and use it in GitHub Desktop.
Save vsemozhetbyt/bff88b6b15e5bb2571ee8e8d9001a84a to your computer and use it in GitHub Desktop.
'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