Skip to content

Instantly share code, notes, and snippets.

@qwert2603
Created January 9, 2019 13:59
Show Gist options
  • Save qwert2603/184f5dde3ec72f07e550938457b01f37 to your computer and use it in GitHub Desktop.
Save qwert2603/184f5dde3ec72f07e550938457b01f37 to your computer and use it in GitHub Desktop.
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