Downloading gists from Github made simple
GithubGist is a place where you can create a private or a public gist i.e store your files either privately or publicly. Let us assume a scenario where you have written a good number of gists for your project and you want to download a set of them. The only way you can do it using GithubGist is to open each and every individual gist to download ZIP or clone via HTTP or SSH.
This article is all about making the above task simpler. Using the commands below, you can even download gists from other github users excluding the private ones until you know their password.
We will be using requests package for this propose. It is an awesome package to send HTTP requests with minimal code.
1. Download the package from PyPI via terminal using pip3
pip3 install requests
Note: To become a root user, run the following command:
sudo pip3 install requests
The script can not run on an online IDE and therefore you can click here to see how it works.
GithubGist API stores information about each user at http://api.github.com/users/username/gists.
- Send a HTTP request to the above url to retrieve information about the user.
- Search for the raw_url of every available gist and sent HTTP requests to retrieve the information about them.
- Manipulated the information to your needs.
This article is contributed by Sri Sanketh Uppalapati. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.