Tweepy(Twitter API)不返回所有搜索结果 [英] Tweepy (Twitter API) Not Returning all Search Results

查看:66
本文介绍了Tweepy(Twitter API)不返回所有搜索结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Tweepy for Twitter 的搜索功能,但由于某种原因,搜索结果仅限于 15 个.这是我的代码

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="Football",rpp=1000)

for result in results:
    print "%s" %(clNormalizeString(result.text))

print len(results)

并且只返回 15 个结果.是不是跟不同页面的结果有关系之类的?

and only 15 results are returned. Does it have something to do with different pages of results or something?

推荐答案

问题更多是关于 Twitter API 而不是 tweepy 本身.

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

根据文档count 参数定义:

每页返回的推文数量,最多 100 条.默认为 15.这以前是旧版本中的rpp"参数搜索 API.

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.

仅供参考,您可以使用 tweepy.Cursor 获得分页结果,如下所示:

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

另见:https://github.com/tweepy/tweepy/issues/197.

希望有所帮助.

这篇关于Tweepy(Twitter API)不返回所有搜索结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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