As a Python programmer, you may already be familiar with GitHub (http://www.github.com), a source code-sharing website, as shown in the following screenshot. You can share your source code privately to a team or publicly to the world using GitHub. It has a nice API interface to query about any source code repository. This recipe may give you a starting point to create your own source code search engine.
To run this recipe, you need to install the third-party Python library requests
by entering $ pip install requests
or $ easy_install requests
.
We would like to define a search_repository()
function that will take the name of author (also known as coder), repository, and search key. In return, it will give us back the available result against the search key. From the GitHub API, the following are the available search keys: issues_url
, has_wiki
, forks_url
, mirror_url
, subscription_url
, notifications_url
, collaborators_url...