Skip to content

Instantly share code, notes, and snippets.

@vinovator
Created December 20, 2015 12:57
Show Gist options
  • Save vinovator/f3693dae04d640bd73ac to your computer and use it in GitHub Desktop.
Save vinovator/f3693dae04d640bd73ac to your computer and use it in GitHub Desktop.
Download all gists from a specific user
# gistsDownloader.py
# Python 3.4
import requests
username = "vinovator"
url = "https://api.github.com/users/" + username + "/gists"
resp = requests.get(url)
gists = resp.json()
for gist in gists:
for file in gist["files"]:
fname = gist["files"][file]["filename"]
furl = gist["files"][file]["raw_url"]
print("{}:{}".format(fname, furl))
pyresp = requests.get(furl)
with open("../vinhub/vinlab/" + fname, "wb") as pyfile:
for chunk in pyresp.iter_content(chunk_size=1024):
if chunk:
pyfile.write(chunk)
print("{} downloaded successfully".format(fname))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment