1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-28 12:43:35 +03:00

feat(package/trend): simple GitHub module results

This commit is contained in:
Louistiti 2019-03-24 15:25:47 +08:00
parent 14de24f6dd
commit 5baec07455
4 changed files with 23 additions and 11 deletions

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "leon", "name": "leon",
"version": "1.0.0-beta.1", "version": "1.0.0-beta.2",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "leon", "name": "leon",
"version": "1.0.0-beta.1", "version": "1.0.0-beta.2",
"description": "Server, packages and web app of the Leon personal assistant", "description": "Server, packages and web app of the Leon personal assistant",
"author": { "author": {
"name": "Louis Grenard", "name": "Louis Grenard",

View File

@ -1,15 +1,18 @@
{ {
"github": { "github": {
"reaching": [ "reaching": [
"I'm reaching the GitHub trends..." "I'm reaching the GitHub trends...",
"I'm finding what's trending on GitHub...",
"Let me find it for you...",
"Let me tell you in a second..."
], ],
"unreachable": [ "unreachable": [
"GitHub is unreachable for the moment, please retry later.", "GitHub is unreachable for the moment, please retry later.",
"I'm having difficulties to reach GitHub, please retry later.", "I'm having difficulties to reach GitHub, please retry later.",
"GitHub seems to be down, please try again later." "GitHub seems to be down, please try again later."
], ],
"test": [ "simple": [
"Here it is: <a href=\"%url%\">%name%</a>" "%rank%. <a href=\"%repository_url%\" target=\"_blank\">%repository_name%</a> created by <a href=\"%author_url%\" target=\"_blank\">%author_username%</a>."
] ]
}, },
"producthunt": { "producthunt": {

View File

@ -43,14 +43,23 @@ def github(string, entities):
r = utils.http('GET', 'https://github.com/trending') r = utils.http('GET', 'https://github.com/trending')
soup = BeautifulSoup(r.text, features='html.parser') soup = BeautifulSoup(r.text, features='html.parser')
limit = 5 limit = 5
reponames = soup.select('.repo-list h3', limit=limit) elements = soup.select('.repo-list li', limit=limit)
authornames = '' authors = soup.select('.repo-list img')
# print('reponames', reponames) for i, element in enumerate(elements):
# print('authornames', authornames) repository = element.h3.get_text(strip=True).replace(' ', '')
author = element.img.get('alt')[1:]
utils.output('inter', 'simple', utils.translate('simple', {
'rank': i + 1,
'repository_url': 'https://github.com/' + repository,
'repository_name': repository,
'author_url': 'https://github.com/' + author,
'author_username': author
}
)
)
except requests.exceptions.RequestException as e: except requests.exceptions.RequestException as e:
return utils.output('end', 'unreachable', utils.translate('unreachable')) return utils.output('end', 'unreachable', utils.translate('unreachable'))
utils.output('inter', 'test', utils.translate('test', { 'url': 'https://getleon.ai', 'name': 'getleon.ai' }))
return utils.output('end', 'done') return utils.output('end', 'done')