Closed GNS7 closed 1 year ago
So handle the exception, are you programming in python?
Yes, but i don't how to handle the exception, do you have any example I could follow?
What exception are you getting?
I get 404 since some users don't exist and the program closes, what i want to do, is that if i give a username and get back a 404, that it would just ignore it and skip to the next user on the list
Show here your traceback you get
Status 404: Endpoint /v1/users/mrpikulslol/usernameinfo/ does not exist Traceback (most recent call last): File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\public.py", line 165, in _send_public_request response.raise_for_status() File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\requests\models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://www.instagram.com/mrpikulslol/?__a=1&__d=dis
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\user.py", line 192, in user_info_by_username user = self.user_info_by_username_gql(username) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\user.py", line 145, in user_info_by_username_gql return extract_user_gql(self.public_a1_request(f"/{username!s}/")["user"]) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\public.py", line 208, in public_a1_request response = self.public_request( ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\public.py", line 105, in public_request raise e # Stop retries ^^^^^^^ File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\public.py", line 99, in public_request return self._send_public_request(url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\public.py", line 196, in _send_public_request raise ClientNotFoundError(e, response=e.response) instagrapi.exceptions.ClientNotFoundError: 404 Client Error: Not Found for url: https://www.instagram.com/mrpikulslol/?__a=1&__d=dis
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\private.py", line 360, in _send_private_request 1
response.raise_for_status()
File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\requests\models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://i.instagram.com/api/v1/users/mrpikulslol/usernameinfo/
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\user.py", line 163, in user_info_by_username_v1 result = self.private_request(f"users/{username}/usernameinfo/") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\private.py", line 535, in private_request raise e File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\private.py", line 520, in private_request self._send_private_request(endpoint, kwargs) File "C:\Users\GNS20\AppData\Roaming\Python\Python311\site-packages\instagrapi\mixins\private.py", line 455, in _send_private_request raise ClientNotFoundError(e, response=e.response, last_json) instagrapi.exceptions.ClientNotFoundError: User not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\GNS20\OneDrive\Documentos\Twitter\instagrapi\main.py", line 30, in
Process finished with exit code 1
raise UserNotFound(e, username=username, **self.last_json)
instagrapi.exceptions.UserNotFound: User not found
according to your traceback you should add an exception
from instagrapi.exceptions import UserNotFound
try:
something
except UserNotFound:
pass
Is your feature request related to a problem? Please describe. Program stops when user is not found
Describe the solution you'd like I'm trying to use a list of users from another platform, so when I try getting their information, considering it doesnt find the same username on instagram that is on the list, it just raises an error and stops the program, I wish it would just skip the non-existing user and continue going down the list.
Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.
Additional context