Created
March 23, 2023 13:25
-
-
Save navicore/88b3766494d5f49d8cbabe3d06818a57 to your computer and use it in GitHub Desktop.
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 requests | |
import json | |
import os | |
# Replace with your GitHub username and personal access token | |
username = 'navicore' | |
token = 'CHANGEME' | |
# API endpoint to fetch repositories sorted by updated_at in descending order | |
api_url = f'https://api.github.com/users/{username}/repos?sort=updated&direction=desc&per_page=25' | |
# Send a request to the GitHub API | |
response = requests.get(api_url, auth=(username, token)) | |
if response.status_code == 200: | |
repos = json.loads(response.text) | |
for repo in repos: | |
ssh_url = repo['ssh_url'] | |
repo_name = repo['name'] | |
print(f'Cloning {repo_name}...') | |
os.system(f'gh repo clone {ssh_url}') | |
else: | |
print(f'Error: {response.status_code}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment