diff --git a/bridges/python/Pipfile b/bridges/python/Pipfile index 6568a43d8..163792c1e 100644 --- a/bridges/python/Pipfile +++ b/bridges/python/Pipfile @@ -7,6 +7,7 @@ name = "pypi" requests = "==2.21.0" pytube = "==9.2.2" tinydb = "==3.9.0" +beautifulsoup4 = "==4.7.1" [dev-packages] diff --git a/bridges/python/Pipfile.lock b/bridges/python/Pipfile.lock index 0dcf627b3..99f95787c 100644 --- a/bridges/python/Pipfile.lock +++ b/bridges/python/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "ef69fb486898e1db2c2908e9b67e156c99e6a7ddaccad88881a5e8f36edd162e" + "sha256": "6b5d87faf7886492cc3d6fdc896041d302523857d81a9e072cbfd627bb204b39" }, "pipfile-spec": 6, "requires": { @@ -16,12 +16,21 @@ ] }, "default": { + "beautifulsoup4": { + "hashes": [ + "sha256:034740f6cb549b4e932ae1ab975581e6103ac8f942200a0e9759065984391858", + "sha256:945065979fb8529dd2f37dbb58f00b661bdbcbebf954f93b32fdf5263ef35348", + "sha256:ba6d5c59906a85ac23dadfe5c88deaf3e179ef565f4898671253e50a78680718" + ], + "index": "pypi", + "version": "==4.7.1" + }, "certifi": { "hashes": [ - "sha256:47f9c83ef4c0c621eaef743f133f09fa8a74a9b75f037e8624f83bd1b6626cb7", - "sha256:993f830721089fef441cdfeb4b2c8c9df86f0c63239f06bd025a76a7daddb033" + "sha256:59b7658e26ca9c7339e00f8f4636cdfe59d34fa37b9b04f6f9e9926b3cece1a5", + "sha256:b26104d6835d1f5e49452a26eb2ff87fe7090b89dfcaee5ea2212697e1e1d7ae" ], - "version": "==2018.11.29" + "version": "==2019.3.9" }, "chardet": { "hashes": [ @@ -53,6 +62,13 @@ "index": "pypi", "version": "==2.21.0" }, + "soupsieve": { + "hashes": [ + "sha256:afa56bf14907bb09403e5d15fbed6275caa4174d36b975226e3b67a3bb6e2c4b", + "sha256:eaed742b48b1f3e2d45ba6f79401b2ed5dc33b2123dfe216adb90d4bfa0ade26" + ], + "version": "==1.8" + }, "tinydb": { "hashes": [ "sha256:67b3b302fc86e0139db545d5abd65bf0e1dadaecee63bd1ff3fe2169810d5387", diff --git a/packages/trend/data/answers/en.json b/packages/trend/data/answers/en.json index fbab06469..0d9decc38 100644 --- a/packages/trend/data/answers/en.json +++ b/packages/trend/data/answers/en.json @@ -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": { } diff --git a/packages/trend/data/answers/fr.json b/packages/trend/data/answers/fr.json index b40dceb2e..414404eed 100644 --- a/packages/trend/data/answers/fr.json +++ b/packages/trend/data/answers/fr.json @@ -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": { } diff --git a/packages/trend/github.py b/packages/trend/github.py index 31122d524..ce2518405 100644 --- a/packages/trend/github.py +++ b/packages/trend/github.py @@ -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')