I am currently using instaloader for scraping followers on Instagram, but it seems that I am not getting the full list of followers as expected. I want to scrape all the followers of a particular account, but my current code doesn't seem to accomplish that.
Here's my code:
# Get instance
import instaloader
L = instaloader.Instaloader()
r = "username to scrape"
# Login or load session
username = "username"
password = r'password'
L.login(username, password) # (login)
# Obtain profile metadata
profile = instaloader.Profile.from_username(L.context, r)
# Print list of followees
follow_list = []
count = 0
for followee in profile.get_followers():
follow_list.append(followee.username)
file = open("prada_followers.txt", "a+")
file.write(follow_list[count])
file.write("\n")
file.close()
count = count + 1
Can someone please help me understand why I might not be getting the complete list of followers? Is there something wrong with my code, or is there a limitation with the instaloader library?
Thank you in advance for your assistance!
One thing i did notice is that you're opening and closing the file inside the loop, which is inefficient, i would instead open the file once outside the loop and write all usernames, then close it after the loop instead.