使用Twitter API
,我通过下面编写的代码获得我的 rate_limiting 信息:
def limit():
twitter = Twitter(auth=OAuth('....'))
g = twitter.application.rate_limit_status()
print g
这很棒,但我得到了这样的大混乱:
{u'rate_limit_context': {u'access_token': u'....'}, u'resources': {u'account': {u'/account/verify_credentials': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/account/settings': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'blocks': {u'/blocks/list': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/blocks/ids': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'users': {u'/users/contributors': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/users/lookup': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}, u'/users/search': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}, u'/users/suggestions/:slug/members': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/users/suggestions/:slug': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/users/show/:id': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}, u'/users/suggestions': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/users/profile_banner': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}, u'/users/contributees': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'friends': {u'/friends/list': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/friends/ids': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'saved_searches': {u'/saved_searches/show/:id': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/saved_searches/list': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/saved_searches/destroy/:id': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'lists': {u'/lists/subscriptions': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/lists/subscribers/show': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/lists/statuses': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}, u'/lists/subscribers': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}, u'/lists/list': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/lists/members/show': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/lists/show': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/lists/memberships': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/lists/members': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}, u'/lists/ownerships': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'search': {u'/search/tweets': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}}, u'application': {u'/application/rate_limit_status': {u'reset': 1371673401, u'limit': 180, u'remaining': 178}}, u'trends': {u'/trends/available': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/trends/closest': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/trends/place': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'followers': {u'/followers/list': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/followers/ids': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'favorites': {u'/favorites/list': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'friendships': {u'/friendships/outgoing': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/friendships/show': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}, u'/friendships/incoming': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/friendships/no_retweets/ids': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/friendships/lookup': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'geo': {u'/geo/similar_places': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/geo/id/:place_id': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/geo/reverse_geocode': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/geo/search': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'direct_messages': {u'/direct_messages/show': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/direct_messages': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/direct_messages/sent': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/direct_messages/sent_and_received': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}, u'statuses': {u'/statuses/retweets_of_me': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/statuses/retweeters/ids': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/statuses/mentions_timeline': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/statuses/user_timeline': {u'reset': 1371672792, u'limit': 180, u'remaining': 177}, u'/statuses/oembed': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}, u'/statuses/show/:id': {u'reset': 1371673471, u'limit': 180, u'remaining': 180}, u'/statuses/home_timeline': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/statuses/retweets/:id': {u'reset': 1371672792, u'limit': 15, u'remaining': 0}}, u'help': {u'/help/tos': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/help/configuration': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/help/privacy': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}, u'/help/languages': {u'reset': 1371673471, u'limit': 15, u'remaining': 15}}}}
不过,我只需要其中的一部分。我只需要知道这方面的剩余限制:
u'/statuses/retweets/:id': {u'reset': 1371672792, u'limit': 15, u'remaining': 0}
我怎样才能得到那个号码?