Skip to content

Instantly share code, notes, and snippets.

@epifanio
Created April 30, 2019 01:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save epifanio/813b0ea86310ecbe8ec0df51ca7fa384 to your computer and use it in GitHub Desktop.
Save epifanio/813b0ea86310ecbe8ec0df51ca7fa384 to your computer and use it in GitHub Desktop.
# first: mkdir user && cd user && cp /path/to/get_gists.py .
# python3 get_gists.py user
import requests
import sys
from subprocess import call
import numpy as np
user = sys.argv[1]
pages = np.arange(1,27,1)
for page in pages:
r = requests.get('https://api.github.com/users/{0}/gists?page={1}'.format(user,page))
for i in r.json():
folder = i['description'][0:255] if i['description'] else i['id']
call(['git', 'clone', i['git_pull_url'], folder])
description_file = './{0}/description.txt'.format(folder)
with open(description_file, 'w') as f:
f.write('{0}\n'.format(i['description']))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment