tweepy を使用して制限の問題に直面しました。スクリプトを実行するたびに、レート制限を超えたというエラーが表示されます。レート制限超過エラーが発生する前に、いくつのリクエストを実行できるかを知る方法があるかどうかを知る必要があります。
3565 次
2 に答える
3
Tweepy は、Rate Limit 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 に答える