launchChrome().then(async () => { const { Chromeless } = require('chromeless') const chromeless = new Chromeless() const links = await chromeless .goto('https://news.ycombinator.com/') .wait('#hnmain') .evaluate(() => { const data = [] document.querySelectorAll(".athing").forEach((element, index) => { data.push({ title: element.querySelector(".storylink").textContent, url: element.querySelector(".storylink").href }) }) return JSON.stringify(data, null, 2) }) console.log(links) await chromeless.end() process.exit(0) }).catch((e) => { console.log(`Oops, there was an error: ${e}`) process.exit(1) })