python - Tweepy(Twitter API)不返回所有搜索结果

标签 python search twitter tweepy

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

results=api.search(q="Football",rpp=1000)

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

print len(results)

并且只返回了 15 个结果。是不是和结果页不同之类的有什么关系?

最佳答案

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

根据documentation , count参数定义:

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 获得分页结果,如下所示:

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 .

希望对您有所帮助。

关于python - Tweepy(Twitter API)不返回所有搜索结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17371652/

相关文章:

python - 如何在pyqt5中对按钮点击使用react

search - 如果在 Elasticsearch 中选择数组字段的另一个聚合选项,如何计算将添加的文档数

ios - 在推特中获取用户名和头像

rss - 自动将 RSS 提要发布到 Twitter 和 FB

python - Django - Disqus 无法识别唯一标识符

Python绘图y轴平均标签不会显示并且日期都很拥挤

python - 如何在 docker 中运行 python 脚本并将脚本动态发送到 docker 容器?

Python Django "and/or"在数据库中搜索

performance - 在 Elasticsearch 中使用过滤器搜索别名非常慢

python - 使用 findall python 从推文中提取@mentions(给出不正确的结果)