From 74bc7398bb7214a70b720a75ae72d09ff25f389d Mon Sep 17 00:00:00 2001 From: Ayush Sharma Date: Tue, 30 Apr 2019 21:32:00 +0530 Subject: [PATCH] Fixing bug where tweet text cannot be found in HTML structure --- social.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/social.py b/social.py index 08564c6..62afc90 100644 --- a/social.py +++ b/social.py @@ -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