Tweepy get retweeters returning max 100

隐身守侯 提交于 2020-01-06 07:14:59

问题


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

I tried to use pagination using tweepy cursor as follows:

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

But it is showing

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

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


回答1:


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

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

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
    )

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.

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



来源:https://stackoverflow.com/questions/48487340/tweepy-get-retweeters-returning-max-100

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!