[英]Get users tweets excluding retweets using tweepy cursor
I want to extract exactly 400 tweets for each user whose id is in a list.我想为每个 id 在列表中的用户准确提取 400 条推文。
I am doing this using Tweepy and Cursor and my code looks like the following:我使用 Tweepy 和 Cursor 执行此操作,我的代码如下所示:
for user_id in users:
for tweet in tweepy.Cursor(
api.user_timeline,
id=user_id
).items(400)
The code above retrieves all the recent (400) tweets but it also includes retweets which I don't want included.上面的代码检索所有最近的 (400) 条推文,但它还包括我不想包含的转推。
Retweets can be filtered using if hasattr(tweet, 'retweeted_status')
but in case the user has retweets, the code will only return (400 - retweets) tweets.可以使用
if hasattr(tweet, 'retweeted_status')
过滤转if hasattr(tweet, 'retweeted_status')
但如果用户有转推,代码将只返回 (400 - 转推) 推文。
As far as I know, there isn't an option in Cursor to exclude the retweets.据我所知, Cursor 中没有排除转推的选项。 Is there a way I can pull this off?
有什么办法可以解决这个问题吗?
Replying as this has been solved.回复因为这个已经解决了。 The
python-twitter
API wrapper provides a parameter include_rts=False
that filters out the retweets python-twitter
API 包装器提供了一个参数include_rts=False
来过滤掉转发
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.