Instagram fetch new followers / save session/cookies using Instagrapi API

Viewed 99

I'm trying to fetch new follwers on Instagram by downloading a list of my followers every 30 seconds using private Instagrapi in python. I found some documentation on how to use the API but can't quite get it to work.

I CAN get the list once every hour or so but not in the needed time interval because of Instagram phishing security/account bans. I don't know how to save sessions or cookies which is exactly where I need help.

Maybe there are other ways to do this but as far as I know the official Instagram Graph API doesn't allow fetching follower lists / follower events. Even if it does, it seems quite elaborate to get access and verify the app. That's why I tried using this API.

I hope someone can explain how to use the API and save cookies/sessions properly or come up with a better idea to do this.

1 Answers

Here's how you can dump cookies to a JSON:

cl = Client()

json.dump(
    cl.get_settings(),
    open('/path/to/cookies.json', 'w')
)

And to load them:

cl = Client(json.load(open('/path/to/cookies.json')))
Related