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

fix(package/trend): when there is no star provided on the GitHub module

This commit is contained in:
Louistiti 2019-04-25 08:10:01 +08:00
parent 815f8c9ba6
commit 563fb40955

View File

@ -66,12 +66,17 @@ def github(string, entities):
author = element.img.get('alt')[1:]
else:
author = '?'
stars = element.select('span.d-inline-block.float-sm-right')[0].get_text(strip=True).split(' ')[0]
separators = [' ', ',', '.']
# Replace potential separators number
for j, separator in enumerate(separators):
stars = stars.replace(separator, '')
hasstars = element.select('span.d-inline-block.float-sm-right')
stars = 0
if hasstars:
stars = element.select('span.d-inline-block.float-sm-right')[0].get_text(strip=True).split(' ')[0]
separators = [' ', ',', '.']
# Replace potential separators number
for j, separator in enumerate(separators):
stars = stars.replace(separator, '')
result += utils.translate('list_element', {
'rank': i + 1,