原推文还是转推? [英] Original tweet or retweeted?
问题描述
我正在将 Tweepy 与 python 一起使用,并试图获取由一组用户创作的原始推文(即,我想在他们的时间线中排除任何实际上是转推的推文).我怎样才能用 Tweepy 做到这一点?我试过这样的事情,我不知道它是否有效:
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)
api.user_timeline()
是否只返回原始推文?或者也转发该用户的推文?
Does the api.user_timeline()
return only original tweets? Or retweets of this user as well?
推荐答案
Tweepy 默认不包含在 user_timeline 中的转发,因此 tweet.retweeted 将始终为 false.要包含转推,您可以将 include_rts 指定为 True,如
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
这篇关于原推文还是转推?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!