Search code examples
pythontwittertweepytweetsrtweet

Get users tweets excluding retweets using tweepy cursor


I want to extract exactly 400 tweets for each user whose id is in a list.

I am doing this using Tweepy and Cursor and my code looks like the following:

for user_id in users:
    for tweet in tweepy.Cursor(
                api.user_timeline,
                id=user_id
    ).items(400)

The code above retrieves all the recent (400) tweets but it also includes retweets which I don't want included.

Retweets can be filtered using if hasattr(tweet, 'retweeted_status') but in case the user has retweets, the code will only return (400 - retweets) tweets.

As far as I know, there isn't an option in Cursor to exclude the retweets. Is there a way I can pull this off?


Solution

  • Replying as this has been solved. The python-twitter API wrapper provides a parameter include_rts=False that filters out the retweets