2014-10-03 11 views
5

Sto usando Tweepy con python e sto cercando di ottenere i tweet originali creati da un gruppo di utenti (ad esempio, voglio escludere qualsiasi tweet nella loro timeline che in realtà è un retweet). Come posso farlo con Tweepy? Ho provato qualcosa di simile e non so se funziona:Tweet originali o ritwittati?

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

fa il ritorno api.user_timeline() solo tweets originali? O anche i retweet di questo utente?

risposta

4

Tweepy per impostazione predefinita non include i retweet in user_timeline pertanto tweet.retweeted sarà sempre true. Per includere i retweet puoi specificare include_rts come True come

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