我在 Python 中使用 tweepy
来搜索推文。我正在使用 tweepy.api.search()
查询较早的推文,发现我无法一次访问 500 条推文。事实上,我不能返回超过 25 个。
我同时使用了 count
和 rpp(每页结果数)
关键字。我似乎无法弄清楚的是,是否不允许我一次访问这么多推文,或者是否存在错误。这是我的代码:
for tweet in api.search(q='obama', count=500, show_user=False, rpp=500,
geocode='38.899722,-77.048363,500mi'):
print tweet.created_at, '\n', tweet.text, '\n\n'
这给了我 25 条推文作为输出。以下是显示其正常工作的前几个:
2015-04-01 16:42:28
"@JonahMarais: me and Michelle Obama are dating guys"
Lot twist.
Its April fools day.
2015-04-01 16:42:05
"@JonahMarais: me and Michelle Obama are dating guys"
SIKE.
2015-04-01 16:38:44
Forget #WinstonChurchill #Obama isn't measuring up to #NevilleChamberlain says http://t.co/6JZqXjUdRH #IranTalks #Israel
最佳答案
您无法在单次搜索中获得 500 条推文,因为 count
参数的最大值为 100——如果您输入任何更大(或负数)的值,它默认为更小的数字。查看 Twitter API 中的 count
参数 GET search/tweets文档:
count - The number of tweets to return per page, up to a maximum of 100.
这意味着对于给定的搜索,您不能获得超过 100 个结果。您可能想查看 Tweepy cursor一种搜索大量推文的简单方法。
关于python - 为什么我不能使用 tweepy 搜索 API 访问超过 25 条推文?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29396433/