Created
January 9, 2019 13:59
-
-
Save qwert2603/184f5dde3ec72f07e550938457b01f37 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 urllib.request | |
import json | |
import os | |
import datetime | |
dumps_dir = 'github dumps {}'.format(datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) | |
os.makedirs(dumps_dir, exist_ok=True) | |
response = urllib.request.urlopen("https://api.github.com/users/qwert2603/repos?per_page=9000") | |
response_string = response.read().decode("utf-8") | |
repos_list = json.loads(response_string) | |
count = len(repos_list) | |
index = 1 | |
for repo in repos_list: | |
try: | |
repo_name = repo.get("name") | |
print("{} / {}. {}".format(index, count, repo_name)) | |
repo_url = "https://github.com/qwert2603/{}/archive/master.zip".format(repo_name) | |
urllib.request.urlretrieve(repo_url, "{}/{}.zip".format(dumps_dir, repo_name)) | |
except Exception as e: | |
print(e) | |
index = index + 1 | |
print("done!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment