from instabot import Bot
import time
import random
# Replace with your Instagram username and password
USERNAME = 'your_username'
PASSWORD = 'your_password'
# Path to the file containing usernames to remove
USERNAMES_TO_REMOVE_FILE = 'usernames_to_remove.txt'
def read_usernames_to_remove(filename):
with open(filename, 'r') as file:
usernames = [line.strip() for line in file]
return usernames
def main():
bot = Bot()
bot.login(username=USERNAME, password=PASSWORD)
usernames_to_remove = read_usernames_to_remove(USERNAMES_TO_REMOVE_FILE)
unfollow_limit = 100 # Maximum unfollow actions per day
min_removals = 80 # Minimum number of removals per day
max_removals = 100 # Maximum number of removals per day
# Calculate a random target number of removals for the day
target_removals = random.randint(min_removals, max_removals)
unfollow_count = 0 # Counter for unfollow actions
for username in usernames_to_remove:
if unfollow_count >= target_removals:
print(f"Target removals ({target_removals}) reached for today. Exiting.")
break
user_id = bot.get_user_id_from_username(username)
if user_id:
bot.unfollow(user_id)
print(f"Unfollowed: {username}")
unfollow_count += 1
# Introduce a randomized delay between 30 to 120 seconds
random_delay = random.randint(30, 120)
time.sleep(random_delay)
else:
print(f"Could not find user: {username}")
bot.logout()
if __name__ == "__main__":
main()