diezo / Ensta

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

Too many redirects (exceeded 30) #49

Closed pama1999 closed 8 months ago

pama1999 commented 8 months ago

This happens sometimes while looping through the followings of a user and the gathering the info of that user, in the gathering process after scraping around 10 I seem to get this error:

image

pama1999 commented 8 months ago

tried to maybe fix it with a sleep delay but doesnt seem to work as well:

def get_user_info(self, username): try: return self.host.profile(username) except requests.exceptions.TooManyRedirects: sleep(10) return self.host.profile(username)

pama1999 commented 8 months ago

compelete traceback:

Traceback (most recent call last): File "f:\3. Fun Projects\InfluSpy\Testing\ensta_test.py", line 34, in get_user_info return self.host.profile(username) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\ensta\SessionHost.py", line 556, in profile return self.guest.profile(username, session=self.request_session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\ensta\Guest.py", line 103, in profile http_response: requests.Response = session.get( ^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\requests\sessions.py", line 602, in get return self.request("GET", url, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\requests\sessions.py", line 725, in send history = [resp for resp in gen] ^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\requests\sessions.py", line 191, in resolve_redirects raise TooManyRedirects( requests.exceptions.TooManyRedirects: Exceeded 30 redirects.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\Parham\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 198, in _run_module_as_main return _run_code(code, main_globals, None, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Parham\AppData\Local\Programs\Python\Python312\Lib\runpy.py", line 88, in _run_code exec(code, run_globals) File "c:\Users\Parham.vscode\extensions\ms-python.python-2023.22.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy__main.py", line 39, in cli.main() File "c:\Users\Parham.vscode\extensions\ms-python.python-2023.22.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 430, in main run() File "c:\Users\Parham.vscode\extensions\ms-python.python-2023.22.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher/../..\debugpy/..\debugpy\server\cli.py", line 284, in run_file runpy.run_path(target, run_name="main") File "c:\Users\Parham.vscode\extensions\ms-python.python-2023.22.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 321, in run_path return _run_module_code(code, init_globals, run_name, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "c:\Users\Parham.vscode\extensions\ms-python.python-2023.22.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code _run_code(code, mod_globals, init_globals, File "c:\Users\Parham.vscode\extensions\ms-python.python-2023.22.0\pythonFiles\lib\python\debugpy_vendored\pydevd_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code exec(code, run_globals) File "f:\3. Fun Projects\InfluSpy\Testing\ensta_test.py", line 54, in user_info = account.get_user_info(user.username) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\Testing\ensta_test.py", line 37, in get_user_info return self.host.profile(username) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\ensta\SessionHost.py", line 556, in profile return self.guest.profile(username, session__=self.request_session) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\ensta\Guest.py", line 103, in profile http_response: requests.Response = session.get( ^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\requests\sessions.py", line 602, in get return self.request("GET", url, kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\requests\sessions.py", line 589, in request resp = self.send(prep, send_kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\requests\sessions.py", line 725, in send history = [resp for resp in gen] ^^^^^^^^^^^^^^^^^^^^^^ File "f:\3. Fun Projects\InfluSpy\venv\Lib\site-packages\requests\sessions.py", line 191, in resolve_redirects raise TooManyRedirects( requests.exceptions.TooManyRedirects: Exceeded 30 redirects.

diezo commented 8 months ago

are you comfortable sharing the entire code? also, please attach full screenshot of the error message as it's not very clear from the text.

diezo commented 8 months ago

are you able to fetch 10 or a few users every time you run the script? or it just no longer works?

pama1999 commented 8 months ago

do you have another commuincation channel? like Discord? if so kindly add me on discord for the source: @pama021

diezo commented 8 months ago

i've sent you a request. i'm on discord as @notdiezo

pama1999 commented 8 months ago

seems like this error is realted to the accs getting locked or flagged

image