Skip to content

Commit

Permalink
feat(package/trend): list GitHub trends in HTML raw
Browse files Browse the repository at this point in the history
  • Loading branch information
louistiti committed Mar 24, 2019
1 parent f406a5a commit 3441629
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 5 deletions.
1 change: 1 addition & 0 deletions bridges/python/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name = "pypi"
requests = "==2.21.0"
pytube = "==9.2.2"
tinydb = "==3.9.0"
beautifulsoup4 = "==4.7.1"

[dev-packages]

Expand Down
24 changes: 20 additions & 4 deletions bridges/python/Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions packages/trend/data/answers/en.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"github": {
"reaching": [
"I'm reaching the GitHub trends..."
],
"unreachable": [
"GitHub is unreachable for the moment, please retry later.",
"I'm having difficulties to reach GitHub, please retry later.",
"GitHub seems to be down, please try again later."
]
},
"producthunt": {
}
Expand Down
8 changes: 8 additions & 0 deletions packages/trend/data/answers/fr.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"github": {
"reaching": [

],
"unreachable": [
"GitHub est inaccessible pour le moment, merci de réessayer plus tard.",
"Je rencontre des difficultés pour atteindre GitHub, merci de réessayer plus tard.",
"GitHub semble ne pas fonctionner correctement, veuillez retenter plus tard"
]
},
"producthunt": {
}
Expand Down
46 changes: 45 additions & 1 deletion packages/trend/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,52 @@

import requests
import utils
from bs4 import BeautifulSoup

def github(string, entities):
"""WIP..."""
"""Grab the GitHub trends"""

# See rate limit here https://developer.github.com/v3/search/#rate-limit
# Without GitHub token, you can make up to 10 requests per minute
# With a GitHub token, you can make up to 30 requests per minute
#
# To improve the GitHub search query, here is the GitHub docs: https://help.github.com/en/articles/searching-for-repositories
#
# Get a new token
#
# 1. https://github.com/settings/tokens
# 2. "Generate new token"
# 3. Put a token description such as "Leon Trend package"
# 4. No need to check any checkbox as we only read public repositories
# 5. Copy directly your token in the config file (SHOW WHICH FILE)

# 1. Grab trendings
# 2. Be able to grab trending per language also. Do an array of languages here via the list https://github.com/trending
# 3. Spot the language in the query and check if it exists in the array
# 4. Be able to grab last week and last month and per language

# Build the languages array according to the languages listed on the trending page

# Leon, give me the 10 GitHub trends of this week for the JavaScript language
# 10, this week, JavaScript
# 1 - 25, today|this week|this month, languages listed on the page (force lowercase for matching)

# Here are the 10 latest GitHub trends of this week for the JavaScript language:
# link? {REPO NAME} by {AUTHOR NAME}
# ...

utils.output('inter', 'reaching', utils.translate('reaching'))

try:
r = utils.http('GET', 'https://github.com/trending')
soup = BeautifulSoup(r.text, features='html.parser')
limit = 5
reponames = soup.select('.repo-list h3', limit=limit)
authornames = ''

print('reponames', reponames)
print('authornames', authornames)
except requests.exceptions.RequestException as e:
return utils.output('end', 'unreachable', utils.translate('unreachable'))

return utils.output('end', 'done')

0 comments on commit 3441629

Please sign in to comment.