Steal Instagram followers - Part 3

November 30, 2022

We saw in the previous article how we could start to follow and interact automatically with other Instagram users who may be interested in our Instagram page. This automation is possible because the Selenium framework is coupled with Kameleo, so Instagram is not flagging the browser.

After you run the script that was showcased in Part 2, you should wait a couple of days. We expect that during this period the accounts we started to follow will follow our page back.

Now, for this 3rd step, we are going to use a script that allows us to unfollow all the people who have followed us back. This allows us to grow our followers while lowering the number of followed accounts.

The “Unfollow Instagram accounts who followed us back” script

The script will check for each account that follows us. If this button exists it means they follow us.

If it does not exist, he will then pass the mouse over the name of the profile to open the window of the profile concerned, and then click on the “follow button to unfollow. Then it will confirm the popup.

Finally, it will wait for the confirmation window to close to repeat the operation with the next account.

Let’s see the code

The follower_remover function is the main function of this script. It is responsible for interacting with Instagram to unfollow accounts.

First, you can see that the function is in an infinite loop. This allows each existing account to be processed. If there are no more accounts, the script will go into the except which contains a break statement, which will take the script out of this infinite loop.

The script will first collect information from each follower. It will then check if the blue follow button that we showed you earlier exist. If it exists, it means that we are not following the account that is following us, so that we can move on to the next account.

Limitations

This script performs the most sensitive actions, such as interacting directly with other users, over a long period and a large number of times. Instagram has implemented several mechanisms to counter this. They take into account the number of people followed according to a certain time, the nature of the actions, the movements of your mouse, etc. The script is configured to follow 6 people, then simulate for 2 minutes a standard use of Instagram, such as browsing photos, and liking some content. These parameters are for information only and may change from one time to another, or from one user to another.

If Instagram detects your activity, the people you follow may not be counted as your followers, and in the worst case, your account may be banned. It is therefore advisable to slow down the script and add a standard navigation moment between several follows. So the script will imitate real human actions.

If Instagram does not offer us this blue follow button, it means that we follow each other with the treated account. So, we need to unfollow it.

The script will then place the mouse over the username of the account in question, which will open a detailed view of his account. It will then click on the follow button to unfollow, and confirm his choice. Then the script will move the mouse to close the detailed view and move on to the next account.

As with the “List relevant Instagram accounts” script, only the first 11 accounts appear at the start. So, once the first 11 accounts have been processed, the script will scroll to load the next ones.

The rest of the script is similar to what we have already seen. After the next 11 accounts are loaded, Instagram’s HTML structure will change, along with paths to names, buttons, etc. The process is therefore the same, but with different access paths in the HTML structure.

The script also includes other small functions, such as write_realistic allowing Selenium to write in a realistic way on Instagram.

Notes

In this script, we didn’t use any proxy, as the script is interacting with your own Instagram account. If you want to run this script with several accounts you manage but on the same machine, we suggest you to use Bright Data residential proxies. Note that Bright Data has a No KYC mode now as well. This will enable you to use their residential proxy network, and visit instagram.com without filling any KYC form. See our integration guide on how to use Kameleo with Bright Data.

See it in action

We have a short video about how the script works.

Download the script

This python project is published on GitHub as “Unfollow Instagram accounts who followed us back”. Please see the “Part 3” folder.

Please note that as the HTML structure of the Instagram website changes over time, this script may need a little maintenance as the CSS selectors may also change over time.

Summary

These 3 scripts make it possible to gain subscribers without major investment, such as proxies, Instagram accounts, or a computer that is powerful enough to manage several profiles at the same time. This is a method that requires patience, and it is not guaranteed to work, as it is up to real users to subscribe in return, and we cannot control that. So you should have some nice content on your Instagram page.

It’s still a good approach to gaining followers, but also a great way to show you how it’s possible to produce an automation script on a famous site like Instagram, and how it’s possible to do this despite their anti-bot policy. We at Kameleo try our best to provide an excellent anti-detect browser.

Get Started

Kameleo Team

Our team consists of IT security experts, professional developers, and privacy enthusiasts who always searching better ways for browser fingerprint protection and developing innovative tools for browser automation and web scraping.