Last active
May 31, 2024 07:29
-
-
Save fabiolimace/3efc99774047396cdf7e2ce5d105cd98 to your computer and use it in GitHub Desktop.
Wget Github stars of a repository
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
#!/usr/bin/bash | |
# | |
# Get the stars count of a Github repository | |
# | |
# Usage: | |
# | |
# github-stars https://github.com/user/repo | |
# | |
function github_stars { | |
local repo=${1} | |
wget -O- "${repo}" 2>&1 \ | |
| grep -E '<span[^<]+<\/span>' \ | |
| grep -E 'id="repo-stars-counter-star"' \ | |
| grep -E -o 'title="[0-9,.]+"' \ | |
| grep -E -o '[0-9,.]+' \ | |
| tr -d ',.'; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Examples:
$ github_stars "https://github.com/torvalds/linux" 172000
$ github_stars "https://github.com/ulid/spec" 8900
$ github_stars "https://github.com/f4b6a3/uuid-creator" 360