Last active
May 13, 2020 21:27
-
-
Save samuelguebo/bf2a3201c9f7baa795c6284b999aae03 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
/** | |
* "Active Users" are registered users who have made at least | |
* one edit in the last thirty days. | |
*/ | |
let apiURI = 'https://meta.wikimedia.org/w/api.php?action=parse&page=List%20of%20Wikipedias&origin=*&format=json' | |
fetch(apiURI) | |
.then(res => res.json()) | |
.then(data => { | |
data = data.parse.text['*'] | |
let page = document.createElement('html') | |
page.innerHTML = data | |
let projects = page.querySelectorAll('table tbody tr td:nth-child(10)') | |
let total = 0 | |
projects.forEach(project => { | |
total += parseFloat(project.innerText.replace(',', '')) | |
}) | |
return total | |
}) | |
.then(total => console.log(`total of active contributors: ${total}`)) | |
.catch(error => console.log(error)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment