subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.21k stars 667 forks source link

Requests blocked after some time #1171

Closed BlackPhoenix134 closed 1 year ago

BlackPhoenix134 commented 1 year ago

We noticed that when running our script it works fine for about 1 or 2 minutes. Liking, commenting and following, we sleep randomly between 10-15 seconds between actions and sometimes 30 seconds between cycles. Then suddenly we get the following error.

requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://i.instagram.com/api/v1/media/2973663574970573838_5911213600/comment/ File "/mnt/networkssd/share/socialmedia/account/scripts/libs/funcs/instagram.py", line 69, in comment return self.client.media_comment(media.id, text) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/mnt/networkssd/share/socialmedia/account/scripts/libs/instagrapi/mixins/comment.py", line 149, in media_comment result = self.private_request( ^^^^^^^^^^^^^^^^^^^^^ File "/mnt/networkssd/share/socialmedia/account/scripts/libs/instagrapi/mixins/private.py", line 461, in private_request raise e File "/mnt/networkssd/share/socialmedia/account/scripts/libs/instagrapi/mixins/private.py", line 446, in private_request self._send_private_request(endpoint, **kwargs) File "/mnt/networkssd/share/socialmedia/account/scripts/libs/instagrapi/mixins/private.py", line 337, in _send_private_request raise LoginRequired(response=e.response, **last_json) libs.framework.exceptions.EngageException: (EngageException(...), LoginRequired('login_required'))

This seems to block the session we save on the disk. It is blocked for further request and we have to create a new one. Any idea how to fix that? Maybe we have to use longer sleeps?

noqcks commented 1 year ago

@BlackPhoenix134 did you ever figure out how to get around this?

sekoakb commented 1 year ago

@BlackPhoenix134 how did you solve it? i exactly have same structure. max 10 interaction per loop, random comment random like and delay after every single client. activity randomly between 5-15 seconds.

noqcks commented 1 year ago

@sekoakb instagram will without notice and randomly terminate a login session, especially if it thinks you're doing bot actions, which is what's happening here.

can't suggest much without seeing your code but,

session termination will happen, just need to login again after some period of time. As long as it's not happening so often that you can't do anything.

sekoakb commented 1 year ago

@noqcks thanks for tips. i have a script to interact with media or comment if its not interacted before (i save interacted media ids to txt file and read them back). Actually i realized it happens mostly after user_medias(userid,amount=20) or after fetching 10 comments on a media.