Skip to content

Instantly share code, notes, and snippets.

@fabiolimace
Last active May 31, 2024 07:29
Show Gist options
  • Save fabiolimace/3efc99774047396cdf7e2ce5d105cd98 to your computer and use it in GitHub Desktop.
Save fabiolimace/3efc99774047396cdf7e2ce5d105cd98 to your computer and use it in GitHub Desktop.
Wget Github stars of a repository
#!/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 ',.';
}
@fabiolimace
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment