From 563fb40955e2deb5c6d0bd064fc9cc8766a6fcaf Mon Sep 17 00:00:00 2001 From: Louistiti Date: Thu, 25 Apr 2019 08:10:01 +0800 Subject: [PATCH] fix(package/trend): when there is no star provided on the GitHub module --- packages/trend/github.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/trend/github.py b/packages/trend/github.py index 06b2f72c..c441425a 100644 --- a/packages/trend/github.py +++ b/packages/trend/github.py @@ -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,