Created
January 11, 2024 10:49
-
-
Save jlhernando/81d92f444575421eeb9aadb8d464484c to your computer and use it in GitHub Desktop.
Scraping Coverage Numbers NodeJS Playwright
This file contains hidden or 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
// Scrape top coverage numbers | |
const topNum = await page | |
.evaluate( | |
([url, selector]) => { | |
const raw = Array.from(document.querySelectorAll(selector), (el) => Number(el.title.replace(/,/g, ''))); | |
const lastUpdated = document.querySelector('div[jslog]').childNodes[1].textContent.trim(); | |
const report = { | |
property: url, | |
error: 0, | |
warning: 0, | |
valid: raw[1], | |
excluded: raw[0], | |
lastUpdated, | |
}; | |
return report; | |
}, | |
[property, reportSelector] | |
) | |
.catch((e) => console.log(e)); | |
console.log(property, topNum); | |
results.push(topNum); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment