[英]How to resolve twitter api rate limit?
Using pip3 install twitter
for a small Python program to retrieve all user's tweets in total year. 使用pip3 install twitter
为一个小型Python程序pip3 install twitter
,以检索一年中所有用户的推文。
utl = t.statuses.user_timeline(count = n, screen_name = name)
Got a error about rate limits, as it shows: 显示有关速率限制的错误,如下所示:
details: {'errors': [{'code': 88, 'message': 'Rate limit exceeded'}]} 详细信息:{'错误':[{'代码':88,'消息':'超出速率限制'}]}
After checking api docs, https://dev.twitter.com/rest/public/rate-limiting , but no idea how to fix it. 检查api文档后, 请https://dev.twitter.com/rest/public/rate-limiting ,但不知道如何解决。
Hopefully, anyone could help. 希望任何人都能提供帮助。 Thanks! 谢谢!
The rate limit page is quite clear, you are restricted to making 180 calls per 15 minutes. 限速页面非常清晰,您只能每15分钟拨打180个电话。
This gives you a few options. 这给您一些选择。
sleep
in there to ensure it never exceeds the limit. 在那里sleep
,以确保它不会超出限制。 The documentation for statuses/user_timeline says: 状态/ user_timeline的文档说:
This method can only return up to 3,200 of a user's most recent Tweets. 此方法最多只能返回用户的最新Tweets中的3200。
and 和
count
Specifies the number of tweets to try and retrieve, up to a maximum of 200 per distinct request.count
指定要尝试和检索的tweet数量,每个不同的请求最多200条。
So you can use count=200
to request all 3,200 statuses in just 16 API calls . 因此,您可以使用count=200
在16个API调用中请求所有3200个状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.