Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const puppeteer = require('puppeteer')
;(async () => {
const browser = await puppeteer.launch()
const page = await browser.newPage()
// Total timeout for all operations is not supported, only supports timeout for individual operations.
// Puppeteer doesn't support aborting of slow operation.
page.setDefaultTimeout(5 * 1000)
await page.goto('https://github.com/avelino/awesome-go')
const p = await page.waitForXPath(`//p[text()[contains(., 'Selenium and browser control tools.')]]`)
const section = await p.evaluateHandle(el => el.nextElementSibling)
const projects = await section.$$('li')
for (const project of projects) {
const link = await project.$('a')
console.log(
"project %s (%s): '%s'",
await link.evaluate(el => el.innerText),
await link.evaluate(el => el.href),
await project.evaluate(el => el.innerText)
)
}
await browser.close()
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment