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

Status 201: JSONDecodeError in public_request #1812

Open isdito opened 7 months ago

isdito commented 7 months ago

Try Instagrapi SaaS with a free trial https://hikerapi.com/p/5GBWznd3

code username = "vadenovias" password = "*****" cl = Client() cl.delay_range = [1, 8] cl.login( username,password) cl.dump_settings("session.json") followers = cl.user_followers_v1(cl.user_id_from_username(username))

prompt Status 201: JSONDecodeError in public_request (url=https://www.instagram.com/vadenovias/?__a=1&__d=dis) >>> Status 201: JSONDecodeError in public_request (url=https://www.instagram.com/vadenovias/?__a=1&__d=dis) >>> Status 201: JSONDecodeError in public_request (url=https://www.instagram.com/vadenovias/?__a=1&__d=dis) >>>

Desktop (please complete the following information):

isdito commented 7 months ago

I change the code to this

cl.load_settings("session.json")
cl.get_timeline_feed() # check session, is valid. If it’s not valid, you’ll get an exception.

user_followers = cl.user_followers(cl.user_id)

print ("SIGUEN-->")
for user_id, user_info in user_followers.items():
    username = user_info.username  # Accede al username del usuario
    print(user_id, username)

But give other error

` Traceback (most recent call last): File "C:\python310\lib\site-packages\instagrapi\mixins\public.py", line 165, in _send_public_request response.raise_for_status() File "C:\python310\lib\site-packages\requests\models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://www.instagram.com/graphql/query/?variables=%7B%22id%22%3A%221531580299%22%2C%22include_reel%22%3Atrue%2C%22fetch_mutual%22%3Afalse%2C%22first%22%3A12%2C%22after%22%3A%22QVFEUUdsMXhYc2hsQTlRVk9GV1ZTS3FPUEZIZkJIVUNaNk5YdWd2Z2g4emc5UlJfRURPdHdWQTRoc0QzcXhQUlg3TVpzNmNpUldWcTlzTjJUa1FqSzdSaQ%3D%3D%22%7D&query_hash=5aefa9893005572d237da5068082d8d5

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\python310\lib\site-packages\instagrapi\mixins\user.py", line 784, in user_followers users = self.user_followers_gql(user_id, amount) File "C:\python310\lib\site-packages\instagrapi\mixins\user.py", line 689, in user_followersgql users, = self.user_followers_gql_chunk(str(user_id), amount) File "C:\python310\lib\site-packages\instagrapi\mixins\user.py", line 655, in user_followers_gql_chunk data = self.public_graphql_request( File "C:\python310\lib\site-packages\instagrapi\mixins\public.py", line 245, in public_graphql_request body_json = self.public_request( File "C:\python310\lib\site-packages\instagrapi\mixins\public.py", line 122, in public_request raise e File "C:\python310\lib\site-packages\instagrapi\mixins\public.py", line 99, in public_request return self._send_public_request(url, **kwargs) File "C:\python310\lib\site-packages\instagrapi\mixins\public.py", line 198, in _send_public_request raise ClientError(e, response=e.response) instagrapi.exceptions.ClientError: 401 Client Error: Unauthorized for url: https://www.instagram.com/graphql/query/?variables=%7B%22id%22%3A%221531580299%22%2C%22include_reel%22%3Atrue%2C%22fetch_mutual%22%3Afalse%2C%22first%22%3A12%2C%22after%22%3A%22QVFEUUdsMXhYc2hsQTlRVk9GV1ZTS3FPUEZIZkJIVUNaNk5YdWd2Z2g4emc5UlJfRURPdHdWQTRoc0QzcXhQUlg3TVpzNmNpUldWcTlzTjJUa1FqSzdSaQ%3D%3D%22%7D&query_hash=5aefa9893005572d237da5068082d8d5

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\python310\lib\site-packages\instagrapi\mixins\private.py", line 360, in _send_private_request response.raise_for_status() File "C:\python310\lib\site-packages\requests\models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://i.instagram.com/api/v1/friendships/1531580299/followers/?max_id=&count=200&rank_token=1531580299_4b7dc35c-c3cf-4773-b615-258bd40b2907&search_surface=follow_list_page&query=&enable_groups=true

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Python37\archivos-pyhton-instagram\insta-2023.py", line 33, in user_followers = cl.user_followers(cl.user_id) File "C:\python310\lib\site-packages\instagrapi\mixins\user.py", line 788, in user_followers users = self.user_followers_v1(user_id, amount) File "C:\python310\lib\site-packages\instagrapi\mixins\user.py", line 755, in user_followersv1 users, = self.user_followers_v1_chunk(str(user_id), amount) File "C:\python310\lib\site-packages\instagrapi\mixins\user.py", line 717, in user_followers_v1_chunk result = self.private_request( File "C:\python310\lib\site-packages\instagrapi\mixins\private.py", line 535, in private_request raise e File "C:\python310\lib\site-packages\instagrapi\mixins\private.py", line 520, in private_request self._send_private_request(endpoint, kwargs) File "C:\python310\lib\site-packages\instagrapi\mixins\private.py", line 459, in _send_private_request raise ClientError(e, response=e.response, last_json) instagrapi.exceptions.ClientError: Please wait a few minutes before you try again.

`

tajbowness commented 7 months ago

https://github.com/subzeroid/instagrapi/issues/1802#issuecomment-1944589499

isdito commented 7 months ago

I'm sorry I don't see where I have to implement

username = "vadenovias" password = "*****" cl = Client() cl.delay_range = [1, 8] cl.login( username,password) cl.dump_settings("session.json") followers = cl.user_followers_v1(cl.user_id_from_username(username))

reggards

tajbowness commented 7 months ago

Hello, you're asking a very beginner to python question. Please learn python before using an api wrapper framework like this

isdito commented 7 months ago

Hello,

If you had examples maybe it would be easier to see. Without basic examples it is difficult for people who don't know that much.

But I doubt that the error is mine when it works on an account with less than 900 users but when I do the "video_boda" one it immediately detects me and banned.

user_info_dict = cl.user_info_by_username_v1(username).dict()

I dont know if you are saying me that put here.

followers = cl.user_followers_v1(user_info_dict )

I don't know if you're telling me to convert it into a dictionary because I never call user_info_by_username in my code.

Yes, I don't know much about Python, but I do know much about education.

A greeting.****

tajbowness commented 7 months ago

As I said, you're asking very beginner questions, please learn Python. If you know Python then it's easy to understand example code and what it's trying to achieve, you don't need a full code example as that is not necessary, what is there is enough, any more is just redundant and unnecessary.

I'm not going to tell you what to do as you don't know Python, and you won't learn anything if I just give you the answer, at your level, you shouldn't just copy and paste code examples you don't understand.

Being a master at education doesn't make you know Python. Learning python makes you know python.

isdito commented 7 months ago

What you say will be, I have developed with Python a program to reveal with the guests' mobiles using the Telegram API https://www.youtube.com/watch?v=VxFEkneaJzE and my own photobooth application for weddings https://www.youtube.com/watch?v=DEDoJIM3Epo. Maybe it's your API that's not right, maybe you're too smart for everyone around you. Thank you for your unparalleled help.

tajbowness commented 7 months ago

The issue you're having isn't from this module, its from basic python syntax you're not following. Please take the time to learn the basics of python for a week or month and you'll understand where I'm coming from.

isdito commented 7 months ago

ok perfect.