Last active
September 20, 2020 23:36
-
-
Save ysmood/12e08d716817b2afa681ba3b9faf97c9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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