Skip to content

Instantly share code, notes, and snippets.

@aarmn
Last active September 20, 2021 16:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aarmn/84f309fa7c0aa0b8ce00f3bfdd1ecb8e to your computer and use it in GitHub Desktop.
Save aarmn/84f309fa7c0aa0b8ce00f3bfdd1ecb8e to your computer and use it in GitHub Desktop.
get stars of a user
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