instagram_private_api icon indicating copy to clipboard operation
instagram_private_api copied to clipboard

Followers Pagination

Open 808arc opened this issue 3 years ago • 2 comments

Hi guys! im new to coding and I was reading documentation and build this script to get list of followers but I keep getting errors. Can some one please explain me what im doing wrong and why?

from instagram_private_api import Client, ClientCompatPatch

user_name = '***'
password = '***'

api = Client(user_name, password)



from random import randint
from time import sleep



user_id = api.username_info('target')['user']['pk']

# Create a list of followers' usernames
usernames = []



next_max_id = followers.get('next_max_id')

while next_max_id:
    delay = randint(20,40)
    print("Sleep " + str(delay) + "s")
    sleep(delay)
    # Get a list of the user's followers
    followers = api.user_followers(user_id, rank_token=api.generate_uuid(),)
    next_max_id = followers.get('next_max_id')

    for follower in followers['users']:
        usernames.append(follower['username'])
    


# Print the list of followers' usernames
print(len(usernames))
print(usernames)


808arc avatar Dec 16 '22 13:12 808arc

Hi! Im going test this code asap! Kindly thank you for showing me how it can work in that way <3

808arc avatar Dec 22 '22 18:12 808arc