Created
June 27, 2023 07:17
-
-
Save 0x4248/7d9b7e40b85949ae8d34ee902a573509 to your computer and use it in GitHub Desktop.
Download all non-forked repositories of a user
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
# Quick Github downloader | |
# Download all non-forked repositories of a user | |
# By: Lewis Evans | |
import os | |
import requests | |
username = input("Enter your GitHub username: ") | |
clone_directory = "./repositories" | |
api_url = f"https://api.github.com/users/{username}/repos?per_page=300" | |
response = requests.get(api_url) | |
if response.status_code == 200: | |
repos = response.json() | |
for repo in repos: | |
if not repo["fork"]: | |
repo_name = repo["name"] | |
repo_url = repo["clone_url"] | |
repo_path = os.path.join(clone_directory, repo_name) | |
os.system(f"git clone {repo_url} {repo_path}") | |
print(f"Cloned repository: {repo_name}") | |
else: | |
print(f"Failed to fetch repositories. Status code: {response.status_code}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment