Skip to content

Instantly share code, notes, and snippets.

@hendrixroa
Created March 9, 2023 22:58
Show Gist options
  • Save hendrixroa/f72187b2b28bed822df8d1af5fada466 to your computer and use it in GitHub Desktop.
Save hendrixroa/f72187b2b28bed822df8d1af5fada466 to your computer and use it in GitHub Desktop.
Getting stars number from github trending
const regexMatchDigits = /\d+/g;
const allStarArticles = document.querySelectorAll(
'.Box-row .d-inline-block.float-sm-right',
);
const allStarReposArray = Array.from(allStarArticles);
const allStarsRepos = allStarReposArray.map((item: HTMLElement | any) => {
const starDigits = item.innerText.match(regexMatchDigits);
return { stars: Number(starDigits[0]) };
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment