def tweet_grab(self, query, count):
tweets = []
try:
tweets_fetched = self.api.search(q=query, count=count)
for tweet in tweets_fetched:
tweets_parsed = {}
tweets_parsed['text'] = tweet.text
tweets_parsed['sentiment'] = self.tweet_sentiment(tweet.text)
if tweet.retweet_count > 0:
if tweets_parsed not in tweets:
tweets.append(tweets_parsed)
else:
tweets.append(tweets_parsed)
return tweets
except tweepy.TweepError: # pragma no cover
print('Error : ' + str(tweepy.TweepError))
评论列表
文章目录