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] user_followers() limit not working #1280

Closed
birdhouses opened this issue Apr 20, 2023 · 8 comments
Closed

[BUG] user_followers() limit not working #1280

birdhouses opened this issue Apr 20, 2023 · 8 comments
Labels
bug Something isn't working

Comments

@birdhouses
Copy link
Contributor

Describe the bug
The limit for fetching followers from a user is not working, because the code keeps making calls after the limit has been reached.

To Reproduce

Code that calls user_followers:

cl = instabot.get_client(Client, ACCOUNT_USERNAME, ACCOUNT_PASSWORD)
user_id = cl.user_id_from_username(username)
users = cl.user_followers(user_id, 5)

instabot.get_client() just calls to the example exception handler method. Client is from instagrapi import Client

Expected behavior
I expect the function to only fetch 5 followers, but the api keeps making calls fetching users

Desktop (please complete the following information):

  • OS: Ubuntu 22.04
  • Python version 3.10.6
  • instagrapi version 1.17.3

Additional context
After getting blocked from making requests by instagram, I saw the following query in the logs:
2023-04-20 23:48:15,022 - INFO - myusername [400] GET https://i.instagram.com/api/v1/friendships/2374691999/followers/?max_id=&count=10000&rank_token=58991008697_849824da-4088-4e16-98c3-6307833f7531&search_surface=follow_list_page&query=&enable_groups=true (269.0.0.18.75, OnePlus 6T Dev)

where count=10000 seems to me that it's causing the issue.

@birdhouses birdhouses added the bug Something isn't working label Apr 20, 2023
@SaeidB
Copy link
Contributor

SaeidB commented Apr 21, 2023

fixed :
#1286

@adw0rd
Copy link
Contributor

adw0rd commented Apr 21, 2023

fixed a437624

@claell
Copy link
Contributor

claell commented Apr 27, 2023

I received a warning from Instagram that I am using automation and my account might get blocked, possibly due to this, but not sure.

So, apparently the count got removed entirely now in the fix; before it seemed fixed to 10000. Does that mean that the internal function always retrieved (and now retrieves) all followers, and then the limit is only applied within Python for the actually returned names?

@adw0rd
Copy link
Contributor

adw0rd commented Apr 27, 2023

@claell Do not use your account to extract data from instagram, you will be banned

@claell
Copy link
Contributor

claell commented Apr 27, 2023

@adw0rd That wasn't the use case, I just wanted to get the followers and followed users for my account (not something like scraping many users). That scope should be fine, right (executed once per day)? Possibly as I ran into #1292, I tried again several (about five) times, also for debugging, and that might be what triggered their detection algorithms.

Thanks for the heads-up, though!

@claell
Copy link
Contributor

claell commented Apr 27, 2023

Ah, I just saw that not https://github.com/adw0rd/instagrapi/pull/1286/files but a437624 got implemented. That changes my interpretation of count getting removed. Sorry for the confusion!

@claell
Copy link
Contributor

claell commented Apr 27, 2023

So as this new implementation now also has a count argument, I assume that the underlying issue was that Instagram recently changed their limits, and it was no longer possible to fire requests (at least for user_following) with a count of 10000.

@claell
Copy link
Contributor

claell commented Apr 27, 2023

Viewing the blame of the relevant file, I see this commit: 0d82741. But I'd assume that has been tested to work before, so likely not the cause of the problem, I hope.

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

4 participants