我正在为 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/