通过Python Instagram API访问HTTP头部细节

2024-05-16 00:06:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Instagram API从标签列表中检索所有照片。从今天开始,我已经达到了API的速率限制(尤其是429错误)。为了调试这个,我一直在尝试如何获取每小时剩余的调用数,并将其合并到脚本中。在

InstagramAPI说,你可以通过HTTP头访问一小时内剩余的调用数,但我不确定如何在Python中访问它。在

The following fields are provided in the header of each response and their values are related to the type of call that was made (authenticated or unauthenticated):

X-Ratelimit-Remaining: the remaining number of calls available to your app within the 1-hour window

X-Ratelimit-Limit: the total number of calls allowed within the 1-hour window

http://instagram.com/developer/limits

如何在Python中访问这些数据?在


Tags: ofthetoapinumber列表标签window
1条回答
网友
1楼 · 发布于 2024-05-16 00:06:33

基于其他一些答案,我认为这是一个更奇特的解决方案,但经过一番研究,我找到了一个非常简单的解决方案!在

import requests

r = requests.get('URL of the API response here')

r.headers

相关问题 更多 >