我遇到了使用 tweepy 的限制问题。每次运行脚本时,我都会收到速率限制超出错误。我需要知道有什么方法可以知道在发生速率限制超出错误之前我可以执行多少个请求。
问问题
3565 次
2 回答
3
Tweepy 提供对速率限制 API 的访问。
import tweepy
consumer_key = 'a'
consumer_secret = 'b'
access_token = 'c'
access_token_secret = 'd'
# OAuth process, using the keys and tokens
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_token, access_token_secret)
# Creation of the actual interface, using authentication
api = tweepy.API(auth)
# Show the rate Limits
print api.rate_limit_status()
然后,您将看到所有可用速率限制的列表以及您剩余的通话次数。
例如:
{ "rate_limit_context" : { "access_token" : "1234" },
"resources" : { "account" : { "/account/login_verification_enrollment" : { "limit" : 15,
"remaining" : 15,
"reset" : 1411295469
},
"/account/settings" : { "limit" : 15,
"remaining" : 15,
"reset" : 1411295469
},
"/account/update_profile" : { "limit" : 15,
"remaining" : 15,
"reset" : 1411295469
},
"/account/verify_credentials" : { "limit" : 15,
"remaining" : 15,
"reset" : 1411295469
}
于 2014-09-21T10:21:23.583 回答
0
可以在 Twitter API 文档中找到速率限制:
于 2013-10-12T23:05:09.260 回答