instascrape icon indicating copy to clipboard operation
instascrape copied to clipboard

Even after passing a valid cookie, the Instagram account gets disabled (update: permanently)

Open marco97pa opened this issue 2 years ago • 2 comments

Some weeks ago I started noticing a bad behavior: even after passing a valid session_id cookie, the Instagram account used to scrape gets disabled after some requests. I need to log in to the Instagram website and manually verify my account using a phone number in order to avoid that my account gets a permanent ban and get a new session_id cookie.

I think that Instagram enforced this behavior against bots: it happened before that I needed to regenerate a valid session_id, but once every 1 or 2 months and it was ok. Now the account gets soft-banned after only a few days of making requests using this API

The code that causes this issue:

# Get Instagram cookies
instagram_sessionid = os.environ.get('INSTAGRAM_SESSION_ID')
headers = {"user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Mobile Safari/537.36 Edg/87.0.664.57",
"cookie": f"sessionid={instagram_sessionid};"}

...

# Get profile of an artist
profile = Profile(artist)
profile = profile.scrape(headers=headers, inplace=False)
...
# Get recent posts of that profile
recents = profile.get_recent_posts()
    
    for recent in recents:
      recent.scrape(headers=headers)
      ...

I run this code every 30 minutes, every day

marco97pa avatar Sep 22 '21 18:09 marco97pa

Update: in the following weeks I needed to manually verify my account sending a video as a proof to Instagram

After 2 months my account has been permanently disabled, even if I passed all the video verification above (I am a human, not a bot).

Screenshot_2021-11-10-16-59-12-327_com instagram android

I used my account only to scrape some data using the code above and I posted some photos once a while.

THIS COMMENT IS TO ALERT ALL THE USERS OF THIS LIBRARY: YOU COULD GET BANNED ANYTIME. Use a secondary Instagram account to avoid loss of data.

marco97pa avatar Nov 10 '21 16:11 marco97pa

I wonder if maintaining an account farm could fix this.

clouedoc avatar Apr 30 '22 19:04 clouedoc