subzeroid / instagrapi

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

[BUG]Status 201 #1957

Open devDarom opened 3 weeks ago

devDarom commented 3 weeks ago

Describe the bug gets a consist status 201

code:

from instagrapi import Client import time

client = Client()

def fetch_user_info(client, user_id_to_fetch): max_retries = 3 retries = 0 while retries < max_retries: try: user = client.user_info(user_id_to_fetch) return user except Exception as e: print(f"Error fetching user info (Attempt {retries+1}/{max_retries}): {e}") retries += 1 time.sleep(5) # Add a delay before retrying return None

try: client.login("username", "pass") print("Login successful!") # Print a success message if login is successful user_id = client.user_id_from_username("yarin_halili")

# Get your followers and the users you follow
followers = client.user_followers(user_id)
following = client.user_following(user_id)

# Create sets of user IDs for easy comparison
followers_ids = {follower.pk for follower in followers}
following_ids = {follow.pk for follow in following}

# Find users you follow who don't follow you back
not_following_back_ids = following_ids - followers_ids

for user_id_to_unfollow in not_following_back_ids:
    user = fetch_user_info(client, user_id_to_unfollow)
    if user:
        print(f"{user.username} ({user.full_name}) does not follow you back.")
        # Uncomment the line below to unfollow the user
        # client.user_unfollow(user_id_to_unfollow)
    else:
        print(f"Failed to fetch info for user ID {user_id_to_unfollow}. Skipping.")

except Exception as e: print(f"Login failed: {e}") # Print an error message if login fails

Traceback Login successful! Status 201: JSONDecodeError in public_request (url=https://www.instagram.com/yarin_halili/?__a=1&__d=dis) >>> Status 201: JSONDecodeError in public_request (url=https://www.instagram.com/yarin_halili/?__a=1&__d=dis) >>> Status 201: JSONDecodeError in public_request (url=https://www.instagram.com/yarin_halili/?__a=1&__d=dis) >>> Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

alexauvray commented 2 weeks ago

+1

Same issue here

pmrncz commented 2 weeks ago

i've got same traceback but my login is successful after those 3 tracebacks