Skip to content

Instantly share code, notes, and snippets.

View blackjacques's full-sized avatar

Rob Gravelle blackjacques

View GitHub Profile
@blackjacques
blackjacques / index.js
Created December 15, 2018 15:37
Demo for the Web Page Scraping with Node.js htmlgoodies.com Article
const puppeteer = require('puppeteer-core');
const clickByText = async (page, text) => {
const links = await page.$x(`//a[contains(@class,'gs-title')][contains(text(), '${text}')]`);
if (links.length > 0) {
await links[0].click();
} else {
console.log(`Link not found: ${text}`);
}