Tweepy (Twitter API) Not Returning all Search Results

前端 未结 2 542
轻奢々
轻奢々 2020-12-15 13:01

I\'m using the search feature with Tweepy for Twitter and for some reason the search results are limited to 15. Here is my code

results=api.search(q=\"Footb         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-15 14:03

    The question is more about Twitter API instead of tweepy itself.

    According to the documentation, count parameter defines:

    The number of tweets to return per page, up to a maximum of 100. Defaults to 15. This was formerly the "rpp" parameter in the old Search API.

    FYI, you can use tweepy.Cursor to get paginated results, like this:

    import tweepy
    
    
    auth = tweepy.OAuthHandler(..., ...)
    auth.set_access_token(..., ...)
    
    api = tweepy.API(auth)
    for tweet in tweepy.Cursor(api.search,
                               q="google",
                               count=100,
                               result_type="recent",
                               include_entities=True,
                               lang="en").items():
        print tweet.created_at, tweet.text
    

    See also: https://github.com/tweepy/tweepy/issues/197.

    Hope that helps.

提交回复
热议问题