diezo / Ensta

🔥 Fast & Reliable Python Package For Instagram API - 2024
https://bit.ly/ensta-discord
MIT License
355 stars 41 forks source link

requests.exceptions.TooManyRedirects #73

Closed Sapu98 closed 6 months ago

Sapu98 commented 7 months ago

I'm trying to clone my insta account by following all the users I follow on my main to play around withour risking a ban.

The code:


from ensta import Host
import time

host = Host("username", "password")  # log into your account

followings = host.followings("username", count=0)
following_names = [follower.username for follower in followings]
target = host.followings("mainAccount_username", count=0)

print(following_names)

for follower in target:
    if follower.username not in following_names:
        followed = host.follow(follower.username)
        print(f"{follower.username}: {followed}")
        time.sleep(30)

After succefully getting the list of follwers, the programs sends the follow request to 7 users and then I get this Exception:

Traceback (most recent call last):
  File "D:\Client\InstaBot\InstaBot\main.py", line 16, in <module>
    followed = host.follow(follower.username)
  File "D:\Client\InstaBot\InstaBot\.venv\lib\site-packages\ensta\SessionHost.py", line 163, in follow
    http_response = self.request_session.post(
  File "D:\Client\InstaBot\InstaBot\.venv\lib\site-packages\requests\sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "D:\Client\InstaBot\InstaBot\.venv\lib\site-packages\requests\sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "D:\Client\InstaBot\InstaBot\.venv\lib\site-packages\requests\sessions.py", line 725, in send
    history = [resp for resp in gen]
  File "D:\Client\InstaBot\InstaBot\.venv\lib\site-packages\requests\sessions.py", line 725, in <listcomp>
    history = [resp for resp in gen]
  File "D:\Client\InstaBot\InstaBot\.venv\lib\site-packages\requests\sessions.py", line 191, in resolve_redirects
    raise TooManyRedirects(
requests.exceptions.TooManyRedirects: Exceeded 30 redirects.

Do you know what can I do to fix it? I've tried to slow down the requests by 30 seconds each but didn't work, also the account seems to not be restricted in any way when I use it from the browser. I'd have joined the discord to ask this question but the link seems to not be working rn :(

diezo commented 7 months ago

seems like you've been logged out because of repeated requests. please delete the ensta-session.txt file to relogin and run your code again.

you can send me a friend request on discord for better assistance. here's my discord username: @gitdiezo

also please do give this repository a star to support ensta. thank you.