我遇到了使用tweepy的限制问题。每次运行脚本时,我都会收到速率限制超出错误。我需要知道有没有办法知道在发生速率限制超出错误之前我可以做多少次请求。
答案 0 :(得分: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
}
答案 1 :(得分:0)
可以在Twitter API文档中找到速率限制: