Tweepy 让转发者返回最多 100 个 [英] Tweepy get retweeters returning max 100

查看:35
本文介绍了Tweepy 让转发者返回最多 100 个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Tweepy 来获取特定推文的所有转发者.我的代码如下:

I am using Tweepy for getting all retweeters of a particular tweet. My code is as follows:

for reTweet in api.retweets(<tweet_id>,100):
      print reTweet

我尝试使用 tweepy 游标使用分页,如下所示:

I tried to use pagination using tweepy cursor as follows:

for status in tweepy.Cursor(api.retweets, <tweet_id>).items():

但它正在显示

raise TweepError('此方法不执行分页')

raise TweepError('This method does not perform pagination')

如何使用 Tweepy API 获取推文的所有转发者?

How to get all retweeters of a tweet using Tweepy API?

推荐答案

如果您查看 Twitter 文档以了解 GET statuses/retweets/:id 你会看到它说:

If you check the Twitter docs for GET statuses/retweets/:id you will see it says:

返回由 id 参数指定的推文的 100 条最新 转推的集合.

Returns a collection of the 100 most recent retweets of the Tweet specified by the id parameter.

如果您查看 tweepy 代码 您将看到您正在使用的函数使用该 API.

And if you check the tweepy code you will see that the function you are using uses that API.

    def retweets(self):
    """ :reference: https://dev.twitter.com/rest/reference/get/statuses/retweets/%3Aid
        :allowed_param:'id', 'count'
    """
    return bind_api(
        api=self,
        path='/statuses/retweets/{id}.json',
        payload_type='status', payload_list=True,
        allowed_param=['id', 'count'],
        require_auth=True
    )

为了获得超过 100 次转发限制,如果是一条仍在转发的推文,您可以做的是多次调用该函数,只要您遵守速率限制,并存储每次调用的唯一结果.

What you could do to get more than the 100 retweets limit, if it's a tweet that is still being retweeted is to call the function several times, as long as you respect the rate limits, and store the unique results from each call.

如果该推文在您开始跟踪之前被转发超过 100 次,您将无法获得较早的转发.

You won't be able to get the older retweets if the tweet was retweeted more than 100 times before you start tracking it.

这篇关于Tweepy 让转发者返回最多 100 个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆