我需要帮助动态计算我向Instagram API的登录请求的重试时间。我想知道我的IP是否在我的桌面上被禁止了,但我不认为这是问题所在,因为在我的手机/笔记本电脑上尝试通话时它也不起作用。我还尝试登录另一个instagram帐户,但这给了我同样的错误。考虑到这些,它让我相信这是代码本身的东西,而不是我的账户
我的story_pload函数,它只被调用一次,所以它不应该重载服务器:
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
429在instagrapi 1.7.0 中修复的错误