ParticipaPY/politic-bots

Change api.search for tweepy.Cursor

Closed this issue · 0 comments

Found out that tweepy.Cursor (http://docs.tweepy.org/en/v3.5.0/cursor_tutorial.html?highlight=tweepy.cursor#introduction) is the recommended method to search and iterate over a list of tweets. Cursor manages pagination automatically but still, we need to manually control the rate limit (see http://docs.tweepy.org/en/v3.5.0/code_snippet.html?highlight=tweepy.cursor)

Example.
tweepy.Cursor(api.search, q=“#hashtag”, count=5, tweet_mode='extended' include_entities=True)

Make sure to include the parameter include_entities so then we can iterate over the hashtags and mentioned user accounts without depending on having the full text of the tweet

Another relevant pointer
https://twittercommunity.com/t/retrieve-full-tweet-when-truncated-non-retweet/75542/17