我将 Tweepy 与 python 一起使用,并试图获取由一组用户创作的原始推文(即,我想排除他们时间轴中实际上是转推的任何推文)。我怎样才能用 Tweepy 做到这一点? 我试过这样的东西,但我不知道它是否有效:
tweets = api.user_timeline(id=user['id'], count=30)
for tweet in tweets:
if not tweet.retweeted:
analyze_tweet(tweet)
api.user_timeline()
是否只返回原始推文?还是转推此用户?
最佳答案
默认情况下,Tweepy 不在 user_timeline 中包含转推,因此 tweet.retweeted 将始终为 false。要包含转推,您可以将 include_rts 指定为 True,例如
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
关于python - 原创推文还是转推?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26181130/