Created
August 23, 2020 15:57
-
-
Save jmpinit/d18cda261bc1b6cd2237a0200a5c04bf to your computer and use it in GitHub Desktop.
Use the GitHub API to retrieve all of a user's stars.
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
| # Combine with https://gist.github.com/jmptable/d961e792902b87f6ffccf0d69d900413 | |
| import json | |
| import time | |
| import requests | |
| def get_stars(user): | |
| page = 0 | |
| stars = [] | |
| while True: | |
| req = requests.get('https://api.github.com/users/{}/starred'.format(user), params={'page': page}) | |
| res = req.json() | |
| if len(res) > 0: | |
| stars += res | |
| else: | |
| break | |
| print('Got page #{}'.format(page)) | |
| page += 1 | |
| time.sleep(1) | |
| return stars | |
| stars = get_stars('jmptable') | |
| with open('stars.json', 'w') as stars_file: | |
| stars_file.write(json.dumps(stars)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment