instagrapi icon indicating copy to clipboard operation
instagrapi copied to clipboard

[BUG]Status 201

Open yarinas5 opened this issue 8 months ago • 3 comments

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):

  • OS: win 10
  • Python version 3.12

Additional context Add any other context about the problem here.

yarinas5 avatar Jun 18 '24 09:06 yarinas5