Skip to content

Commit

Permalink
Added language option in github api
Browse files Browse the repository at this point in the history
  • Loading branch information
sirfoga committed Aug 18, 2017
1 parent b98b374 commit ac8adbb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ All notable changes to this project will be documented in this file.

### 4.6.3

###

### Added
- language option in github api

### 4.6.2

Expand Down
13 changes: 9 additions & 4 deletions hal/internet/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,24 @@ def __init__(self, api_type):
super(GithubApi, self).__init__(GithubApi._API_URL_TYPE[api_type])

@staticmethod
def get_trending_daily():
def get_trending_daily(lang=""):
"""
:param lang: str
Coding language
:return: []
List of GithubUserRepository
"""

url = "https://github.com/trending?since=daily"
url = "https://github.com/trending/"
url += str(lang).lower().replace(" ", "") + "?since=daily"
api_content_request = urllib.request.Request(url)
api_content_response = urllib.request.urlopen(
api_content_request).read().decode("utf-8") # parse response
soup = BeautifulSoup(api_content_response, "lxml") # html parser
raw_repo_list = soup.find_all("ol", {"class": "repo-list"})[
0].find_all("li")
raw_repo_list = soup.find(
"ol", {"class": "repo-list"}
).find_all("li")

repos_list = []
for repo in raw_repo_list:
details = repo.find_all("div")[0].a.text.split("/")
Expand Down

0 comments on commit ac8adbb

Please sign in to comment.