Last active
September 20, 2021 16:10
-
-
Save aarmn/84f309fa7c0aa0b8ce00f3bfdd1ecb8e to your computer and use it in GitHub Desktop.
get stars of a user
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
import urllib.request, json | |
def users_stars_raw(users): | |
users_stars = {} | |
for user in users: | |
i=1 | |
users_stars[user] = [] | |
while True: | |
with urllib.request.urlopen("https://api.github.com/users/aarmn/starred?per_page=100&page=" + str(i)) as url: | |
page_out=json.loads(url.read().decode()) | |
if (len(page_out)): | |
users_stars[user] += page_out | |
else: | |
break | |
i+=1 | |
all_stars=set(users_stars.values()) | |
def user_stars(*users): | |
all_stars = users_stars_raw(users) | |
out=[] | |
for item in all_stars: | |
out.append([item["full_name"],item["description"],item["owner"]["avatar_url"],item["owner"]["login"],item["owner"]["html_url"],item["stargazers_count"],item["forks_count"]]) | |
return out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment