Created
December 20, 2015 12:57
-
-
Save vinovator/f3693dae04d640bd73ac to your computer and use it in GitHub Desktop.
Download all gists from a specific user
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
| # 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