subzeroid / instagrapi

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

instagram banned my account #581

Open helallao opened 2 years ago

helallao commented 2 years ago

I made a meme page generator, it just copies posts from my meme pages list but instagram banned my account and deleted all my posts.

Screenshot_20220218-152603_Instagram

I added phone number but my script stopped working for this account

Doesn't this repository use private api? Why i got banned? How can i pass this?

code:


from datetime import datetime
import instagrapi
import random
import time
import os

cl = instagrapi.Client()
cl.request_timeout = 5

cl.login('username', 'password')

history = []
copy_list = ['dugunteroru', 'editah4z', 'tassakshitpost', 'boreklipogaca', 'medraxhumor', 'jolithex', 'palanin_mekani', 'igcoplugu', 'the_.green._goblin', 'parttimeejderyaavcisi', 'wiptieyerli']

def clear_files():
    for i in os.listdir('./myfiles/'):
        os.remove(f'./myfiles/{i}')

def send_follow(id):
    for i in cl_2.user_following(cl_2.user_id, 10):
        try:
            cl_2.user_unfollow(i)

        except:
            break

    comments = cl_2.media_comments(id)

    for i in comments[:10]:
        try:
            id = cl_2.user_id_from_username(i.user.username)

            cl_2.user_follow(id)

        except:
            break

        #follow users from the post comments

def send_post():
    while True:
        page_name = random.choice(copy_list)
        copy_page = cl_2.user_id_from_username(page_name)

        post = random.choice(cl_2.user_medias(copy_page, 10))

        if post.code not in history:
            history.append(post.code)
            break

        #choose a random post from page, and save code to history

    send_follow(post.id)

    if post.media_type == 1:
        try:
            photo = cl_2.photo_download(cl_2.media_pk_from_code(post.code), './myfiles')

            cl_2.photo_upload(photo, post.caption_text)

            clear_files()

        except:
            pass

    elif post.media_type == 2 and post.product_type == 'feed':
        try:
            video = cl_2.video_download(cl_2.media_pk_from_code(post.code), './myfiles')

            cl_2.video_upload(video, post.caption_text)

            clear_files()

        except:
            pass

    elif post.media_type == 2 and post.product_type == 'igtv':
        try:
            igtv = cl_2.igtv_download(cl_2.media_pk_from_code(post.code), './myfiles')

            cl_2.igtv_upload(igtv, post.caption_text)

            clear_files()

        except:
            pass

    elif post.media_type == 2 and post.product_type == 'clips':
        try:
            clip = cl_2.clip_download(cl_2.media_pk_from_code(post.code), './myfiles')

            cl_2.clip_upload(clip, post.caption_text)

            clear_files()

        except:
            pass

    elif post.media_type == 8:
        try:
            album = cl_2.album_download(cl_2.media_pk_from_code(post.code), './myfiles')

            cl_2.album_upload(album, post.caption_text)

            clear_files()

        except:
            pass

def run():
    while True:
        time.sleep(60 * random.randint(20, 45))
        #sleep 20 ~ 45 minutes

        send_post()

run()
msr8 commented 2 years ago

To get your account unbanned, temporarily give insta your phone number (you can remove it after). And use client.load_settings as shown here

helallao commented 2 years ago

i edited codes for show here, i was already using client.set_settings(), it's not the real reason of why i got banned.

Jmallone commented 2 years ago

If you only post with your personal account and nothing else, I recommend using the official API, differences:


I have an account that generates images and I use the official API to post to the feed, and the instagrapi to post to Stories. And it's been 8 months since everything is going well, maybe it's an alternative for you.

rehman-00001 commented 1 year ago

but using the official API requires facebook to verify/review the app right?

Screenshot 2023-04-08 at 6 34 51 PM

@Jmallone , how did you get past this step?

diezo commented 10 months ago

This could possibly be because instagrapi doesn't have an auto session management feature and you've logged in a lot of times.

You should try using ensta. While it uses the web api, it stores your previous session locally.