Skip to content

Instantly share code, notes, and snippets.



Created Jul 29, 2020
What would you like to do?
Fun with browser automation
const puppeteer = require('puppeteer');
async function getLink (url, xpathExpression) {
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto(url);
let link = await page.$eval(xpathExpression, anchor => { return anchor.href; });
await browser.close();
return link;
(async () => {
getLink('', 'a[aria-label="Download BlueJeans for Mac"]').then(o => console.log(o));
getLink('', 'table:first-of-type a.button').then(o => console.log(o));
getLink('','a[href^=""]').then(o => console.log(o));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment