Original tweet or retouched?

I am using Tweepy with python and trying to get the original tweets created by the user (i.e. I want to exclude any tweets on their timeline, which is actually retweet). How can I do this with Tweepy? I tried something like this and I don't know if it works:

tweets = api.user_timeline(id=user['id'], count=30) for tweet in tweets: if not tweet.retweeted: analyze_tweet(tweet) 

Does api.user_timeline() return only original tweets? Or retweets of this user?

+5
source share
1 answer

Tweepy does not include retweets in user_timeline by default, so tweet.retweeted will always be false. To enable retweets, you can specify include_rts as True, for example

 tweets= api.user_timeline(id=user['id'], count=30,include_rts=True) for tweet in tweets: if not tweet.retweeted: analyze_tweet(tweet) else: #do something with retweet 
+4
source

Source: https://habr.com/ru/post/1203942/


All Articles