Created
April 24, 2024 07:39
-
-
Save WCY-dt/15bc10d87eefb7cef62a9a5d68a987f7 to your computer and use it in GitHub Desktop.
Get all the repos starred as a json file
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
import requests | |
import json | |
def get_starred(username='github'): | |
url = 'https://api.github.com/users/{}/starred'.format(username) | |
headers = { | |
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3' | |
} | |
response = requests.get(url, headers=headers, verify=False) | |
if response.status_code == 200: | |
return response.text | |
return None | |
def main(): | |
data = get_starred('wcy-dt') | |
if data: | |
with open('starred.json', 'w', encoding='utf-8') as f: | |
f.write(data) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment