Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Status 201 #1957

Open
devDarom opened this issue Jun 18, 2024 · 2 comments
Open

[BUG]Status 201 #1957

devDarom opened this issue Jun 18, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@devDarom
Copy link

devDarom commented Jun 18, 2024

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.

@devDarom devDarom added the bug Something isn't working label Jun 18, 2024
@alexauvray
Copy link

+1

Same issue here

@pmrncz
Copy link

pmrncz commented Jun 25, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants