subzeroid / instagrapi

🔥 The fastest and powerful Python library for Instagram Private API 2024
https://hikerapi.com/p/bkXQlaVe
MIT License
4.21k stars 667 forks source link

[BUG] Suspicious activity #690

Closed Rain1950 closed 1 year ago

Rain1950 commented 2 years ago

Describe the bug Basically instagram detects suspicious activity on my account anytime i post anything. I need to verify my email after each posting session.

To Reproduce `from genericpath import exists from time import sleep from instagrapi import Client import os from PIL import Image

files = os.listdir("Resources/Temp/")

if files != None: with open("Resources/login.txt","r") as f: Login = f.readlines()[0] f.close() with open("Resources/test.txt","r") as f: Password = f.readlines()[0] f.close()
cl = Client() sleep(10) cl.login(Login,Password) for file in files: sleep(10) image = Image.open("Resources/Temp/" + file) if image.size[0] > image.size[1]: image = image.resize((image.size[1],image.size[1])) else: image = image.resize((image.size[0],image.size[0]))
Converted_image = image.convert("RGB") Converted_image.save("Resources/Temp/" + "Resized" + file.replace("png","jpg") ) os.remove("Resources/Temp/" + file) cl.photo_upload("Resources/Temp/" + "Resized" +file.replace("png","jpg"),caption= u"😅") os.remove("Resources/Temp/" + "Resized" + file.replace("png","jpg") )
`

Traceback there isn't

Expected behavior Well it was working for months but now it seems that instagram figured out that something is wrong. It's just really boring to verify email each time my bot posts on my account.

Screenshots Can't provide that rn but i will if it will be needed.

Desktop (please complete the following information):

kingbotss commented 2 years ago

Login in the app, try again.

Rain1950 commented 2 years ago

Login in the app, try again.

What do you mean? I'm logging in everyday.

ghrlt commented 2 years ago

You should not fresh login every time you run the script.

I recommend you to save session settings in a file, and use it for your next session.

import instagrapi
import json
import os

if 'session.json' in os.listdir():
    with open('session.json', 'r') as f:
        cl_session = json.load(f)
else:
    cl_session =  {}

cl = instagrapi.Client(cl_session)
cl.login(username, password)

with open('session.json', 'w') as f:
    json.dump(cl.get_settings(), f)

Be aware that this session.json file permit anyone to login to your account. Keep it safe.

adw0rd commented 2 years ago

@ghrlt try to use cl.load_settings and cl.dump_settings https://adw0rd.github.io/instagrapi/usage-guide/interactions.html

Rain1950 commented 2 years ago

Okay thanks this seems to be working. Sorry for causing a trouble!