instagram_private_api
instagram_private_api copied to clipboard
Followers Pagination
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)
Hi! Im going test this code asap! Kindly thank you for showing me how it can work in that way <3