ARTICLE AD BOX
I am trying to automate Instagram using the instagrapi library in Python.
Here is my code:
from instagrapi import Client import os client = Client() client.set_device({ "app_version": "269.0.0.18.75", "android_version": 26, "android_release": "8.0.0", "dpi": "480dpi", "resolution": "1080x1920", "manufacturer": "samsung", "device": "SM-G950F", "model": "Galaxy S8", "cpu": "samsungexynos8b895" }) try: if os.path.exists("session.json"): print("session.json found. Loading session...") client.load_settings("session.json") try: client.get_timeline_feed() print("Session working ✅") except Exception as e: print("Session expired, login again. Error:", e) client.login("testingautomatation", "testingAutomatation123") client.dump_settings("session.json") print("New session saved and session.json updated ✅") else: print("session.json not found. Logging in...") client.login("testingautomatation", "testingAutomatation123") client.dump_settings("session.json") print("Login successful and session.json created ✅") except Exception as err: print("❌ Error:", err)At first I wrote without client-side device. The time when I ran that in Instagram for that account, I received a security alert, and it has blocked from logging from system with code.
So I've taken AI suggestions, and it said to write as client-side set device, and I added the above code, and still I'm facing the issue. In the terminal, it is showing some password incorrect error, even though I've entered them correctly.
I got:
session.json not found. Logging in...
❌ Error: The password you entered is incorrect. Please try again. If you are sure that the password is correct, then change your IP address, because it is added to the blacklist of the Instagram Server
in the terminal.
Can anyone say is there any mistake in my approach or any issues from security check in Instagram?
