在 instagram api 登录(instagrapi)上无法通过 429 错误(请求太多)
Posted
技术标签:
【中文标题】在 instagram api 登录(instagrapi)上无法通过 429 错误(请求太多)【英文标题】:Cant get past 429 Error (too many requests) on instagram api login (instagrapi) 【发布时间】:2021-06-28 15:04:59 【问题描述】:我需要帮助确定我对 Instagram API 的登录请求的动态重试时间。我想知道我的 IP 是否已在我的桌面上被禁止,但我认为这不是问题,因为在我的手机/笔记本电脑上尝试通话时它也不起作用。我也尝试登录到不同的 Instagram 帐户,但这给了我同样的错误。鉴于这些,我相信这是代码本身的东西,而不是我的帐户
我的 story_upload 函数,它只被调用一次,所以它不应该超载服务器:
def upload_post():
cl = Client()
cl.login("username", "password")
image_path = "/home/Spotify365/mysite/static/images/testing.png"
cl.photo_upload_to_story(path=image_path, caption="Generated Automatically by Spotify365", links=[StoryLink(webUri='https://spotify365.pythonanywhere.com/')])
完整的错误日志:(成功,直到它尝试登录 API,引发错误 429)
2021-04-01 12:52:15,655: username [200] POST https://i.instagram.com/api/v1/accounts/contact_point_prefill/ (169.3.0.30.135, Xiaomi capricorn)
2021-04-01 12:52:15,711: username [200] POST https://i.instagram.com/api/v1/accounts/get_prefill_candidates/ (169.3.0.30.135, Xiaomi capricorn)
2021-04-01 12:52:15,747: username [200] POST https://i.instagram.com/api/v1/accounts/contact_point_prefill/ (169.3.0.30.135, Xiaomi capricorn)
2021-04-01 12:52:15,800: username [200] POST https://i.instagram.com/api/v1/launcher/sync/ (169.3.0.30.135, Xiaomi capricorn)
2021-04-01 12:52:15,878: username [200] POST https://i.instagram.com/api/v1/qe/sync/ (169.3.0.30.135, Xiaomi capricorn)
2021-04-01 12:52:15,982: username [429] POST https://i.instagram.com/api/v1/accounts/login/ (169.3.0.30.135, Xiaomi capricorn)
2021-04-01 12:52:15,982: Status 429: Too many requests
2021-04-01 12:52:15,983: Exception on /instaStory [GET]
Traceback (most recent call last):
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/instagrapi/mixins/private.py", line 183, in _send_private_request
response.raise_for_status()
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/requests/models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 429 Client Error: - for url: https://i.instagram.com/api/v1/accounts/login/
**NO MATCH**
During handling of the above exception, another exception occurred:
**NO MATCH**
Traceback (most recent call last):
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/Spotify365/mysite/flask_app.py", line 50, in isStory
upload_post()
File "/home/Spotify365/mysite/flask_app.py", line 43, in upload_post
cl.login("username", "password")
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/instagrapi/mixins/auth.py", line 341, in login
if self.private_request("accounts/login/", data, login=True):
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/instagrapi/mixins/private.py", line 316, in private_request
raise e
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/instagrapi/mixins/private.py", line 303, in private_request
self._send_private_request(endpoint, **kwargs)
File "/home/Spotify365/.virtualenvs/myenv/lib/python3.8/site-packages/instagrapi/mixins/private.py", line 244, in _send_private_request
raise PleaseWaitFewMinutes(e, response=e.response, **last_json)
instagrapi.exceptions.PleaseWaitFewMinutes: Please wait a few minutes before you try again.
我尝试调用 jqXHR.getAllResponseHeaders() 以希望获得“Retry-After”标头,但这并没有真正帮助我:
connection: keep-alive
content-length: 290
content-type: text/html; charset=utf-8
date: Thu, 01 Apr 2021 13:13:42 GMT
server: PythonAnywhere
【问题讨论】:
【参考方案1】:在 instagrapi 1.7.0 中修复了 429 错误
【讨论】:
以上是关于在 instagram api 登录(instagrapi)上无法通过 429 错误(请求太多)的主要内容,如果未能解决你的问题,请参考以下文章
使用 Instagram 新图形 API 在 iOS 应用程序中登录 Instagram
ios - Instagram用新的instagram图表api登录?
如何为 Instagram 基本显示 API 实现 Instagram 或 Facebook 登录按钮的继续?