ping / instagram_private_api

A Python library to access Instagram's private API.
MIT License
2.96k stars 615 forks source link

Error 429-Related Issue (Occurring Much More Frequently) #218

Open james-scheckowitz opened 4 years ago

james-scheckowitz commented 4 years ago

Please follow the guide below


Before submitting an issue, make sure you have:

Which client are you using?


Describe your issue

My issue is related to HTTP Error 429.

To give some background, I predominantly use instagram_private_api to pull follower and following lists of Instagram accounts of interest. To limit the number of my calls within a given period of time, I incorporated time.sleep() as people have recommended. Up until recently, doing so would work just fine, and I would have no issues pulling more follower and following data after hitting HTTP Error 429 and going into sleeps of 5 minutes for each occurrence.

However, I am not encountering Error 429 much more frequently than I have been over the past ~9 months. My biggest predicament is that once I hit Error 429 even once for one Instagram account, I'll keep encountering the error after any set amount of sleep time (from 10 minutes to multiple hours). The Instagram accounts I have tested also appear to work without any issue from the UI itself, so I was wondering if anyone else has been encountering any further Error 429-related issues as of late.


Paste the output of python -V here:

Code:

# Example code that will produce the error reported
follower_list = [follower1, follower2, follower3]

for x in follower_list:
    try:
        ig_name = x 

        def ig_name_to_id(ig_name, Client):
            return Client.username_info(ig_name)['user']['pk']
        ig_id = ig_name_to_id(ig_name, api)
        rank_token = api.generate_uuid()

        ## Create empty list to add followings into
        following = []

        ## Pull followings
        try:
            results = api.user_following(ig_id, rank_token) ##Issue comes about here.
            following.extend(results.get('users', []))
            next_max_id = results.get('next_max_id')
            while next_max_id:
                try:
                    results = api.user_following(ig_id, rank_token, max_id=next_max_id)
                    following.extend(results.get('users',[]))
                    next_max_id = results.get('next_max_id')
                except:
                    print('time to sleep for 5 minutes')
                    time.sleep(300)
                    print('time to continue')
        except:
            print('time to sleep for 5 minutes')
            time.sleep(300)
            print('time to continue')

Error/Debug Log:

ClientThrottledError: Please wait a few minutes before you try again.

During handling of the above exception, another exception occurred:
dvingerh commented 4 years ago

There is no fix for this, you're simply hitting Instagram's request threshold and/or triggering anti-spam measures. One thing to try is randomizing the timeout between requests but it's unlikely that this will have any effect as there are undoubtedly many other factors being taken into account in Instagram's anti-spam system.

thematrixdev commented 4 years ago

I have been creating a new Instagram account once the currently using account is banned. However, even new account is not working (new domain name, new IP address). Error happens during registration process. I do put a random sleep time between character typing and also data pulling. I cannot pull any data from Instagram for weeks...

Crarkie commented 4 years ago

Use web api to get followers. There're no these problems yet.

maaxap commented 4 years ago

@james-scheckowitz @dvingerh @Crarkie @thematrixdev By the way, guys, did you manage to get followers via Web API effectively, without spending, let's say, 30 hours for fetching 1M followers?