Fixing bug where tweet text cannot be found in HTML structure

pull/7/head
Ayush Sharma 2019-04-30 21:32:00 +05:30
parent 91a325e937
commit 74bc7398bb
1 changed files with 10 additions and 1 deletions

View File

@ -45,8 +45,17 @@ def getTweets():
for tweet in timeline:
tweet_id = tweet['data-item-id']
tweet_text = tweet.select('p.tweet-text')[0].get_text()
try:
tweet_text = tweet.select('p.tweet-text')[0].get_text()
except:
helpers._info('getTweets() => No tweet text found. Moving on...')
continue
all_tweets.append({"id": tweet_id, "text": tweet_text})
return all_tweets if len(all_tweets) > 0 else None