Steal Instagram followers – Part 1

During the summer an intern joined us at our HQ. His task was to build an Instagram bot with Kameleo + Selenium to see how easy it is to get started with Kameleo. He could explore the features of Kameleo and build the following bot within 2 weeks.

Introduction to Instagram automation

Instagram is one of the most important social networks in terms of users, but also in terms of influence. Automating Instagram tasks can be useful to increase your number of followers, and interactions with your account such as likes or comments, which can give you visibility. But Instagram protects itself a lot against these methods, and the task can be very difficult or even impossible without good tools. So, we will see how this can be done via 2 methods that we will present here, thanks to automation tools coupled with Kameleo.

Steps of this method

For this first method called “Instagram follower stealer”, we aim to attract real people on Instagram, so that they can subscribe and interact with our account. If these accounts start to follow our Instagram page, they will be 100% organic traffic to our account with an interest in our account. We will only use our account for this method. This will happen in 3 steps:

  1. We will collect the names and URLs of a large number of users subscribed to a page or a personality known to Instagram. This will allow us to have an important data source, quickly and easily.
  2. Thanks to the data previously collected, we will subscribe to each user, and interact with their posts if possible. We hope that they will follow us back.
  3. After a little wait following step 2, we will unfollow all the people who have followed us back

We will show you how to automate each step in a separate article.

How can Kameleo be useful for this task?

Here we will use an automation tool called Selenium, its default browser is not at all made to be invisible on the web, and Instagram will recognize directly that it is not a real user who uses the browser, but a robot.

Thanks to Kameleo, the profiles that we will use to navigate are sure to pass the verification that Instagram does on the browser. This, therefore, reduces the risk that Instagram will flag the account.

The “List relevant Instagram accounts” script

The script will load URLs of the accounts with many followers that you want to “steal”. These accounts should be somehow relevant to your page. If you have a page about football, then you should aim for some other popular accounts that post about football often. These accounts must have access to the followers of the page you want to “steal”.

This football.newz page is perfect because we can scroll and access all the followers.

The script will then collect the URL of each account, as well as their name. The script will collect information from the following accounts that are visible. After some waiting time the script will scroll down for more accounts, and start again. There is a fairly long timer after each scroll, to prevent the account from being flagged. The script waits about 20 seconds, this is an indicative value.

Let’s see the code

The scrap_user_account function is the main function of the script. It will collect our data.

It allows you to proceed with all the URLs given in the text file thanks to the first “for” loop, then to collect the right amount of data per Instagram page thanks to the 2nd “for” loop.

The script will then retrieve the data that interests us, namely the URL of each profile, its name, or if it does not exist, its username. Finally, for every 11 accounts harvested, the script scrolls down to load new accounts.

The rest of the script performs the same actions; however, it is slightly different because once the first 11 accounts have been collected and the bot has scrolled, the HTML structure of the site changes and the data collection process also changes slightly.

The script is composed of other relatively simple functions, such as the read_file function allowing one to read a file, write_in_file allowing one to write in a text file, or write_realistic allowing one to write in a realistic way on Instagram as humans do.

The script allows you to connect to Instagram using login credentials, in a classic way, or using an existing Kameleo profile containing connection cookies, in order to be already connected to Instagram.

It is possible to configure some variables of this script in the configfile.ini file which is in the same folder as the script. Each line of this file is described in the README.md file.

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 “Instagram follower stealer”. Please see the “Part 1” 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.

Let’s see the next part of this article.

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.