gpt4 book ai didi

python - 通过 Python Instagram API 访问 HTTP header 详细信息

转载 作者:太空宇宙 更新时间:2023-11-03 18:06:06 25 4
gpt4 key购买 nike

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

Instagram API 表示您可以通过 HTTP header 访问一小时内剩余的通话次数,但我不确定如何在 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 中访问这些数据?

最佳答案

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

import requests

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

r.headers

关于python - 通过 Python Instagram API 访问 HTTP header 详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26875520/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com