Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Original tweet or retweeted?

I am using Tweepy with python and trying to get the original tweets authored by set of users (i.e., I want to exclude any tweet in their timeline that is actually a retweet). How can I do this with Tweepy? I tried something like this and I do not 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 the api.user_timeline() return only original tweets? Or retweets of this user as well?

like image 569
amaatouq Avatar asked Oct 03 '14 14:10

amaatouq


1 Answers

Tweepy by default doesn't include retweets in user_timeline therefore tweet.retweeted will always be false. To include retweets you can specify include_rts as True like

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
like image 91
geo_pythoncl Avatar answered Oct 03 '22 07:10

geo_pythoncl