Thought leadership from the most innovative tech companies, all in one place.

Find Out Who Doesn’t Follow You on Instagram

Have you ever thought of finding out who doesn't follow you back on Instagram? But you are super lazy like me to find that out? Sometimes, it gets really annoying. Well, if you are stuck in such a situation, I have a perfect Python-based solution for you!

There are a lot of platforms, where you can get to know about these details. But one of the major concerns that's associated with these platforms is security. There's always a fear of leaking your account credentials while using such platforms. So, today we'll be looking at an amazing Selenium-based library called InstaPy and along with that, I'll also guide you step by step to make sure you too can find the person who doesn't follow you back on Instagram.

Notice: Neither the author of this blog nor the platform on which it is published will be responsible for any undesirable actions on your account or consequences faced.

So, please follow the instructions thoroughly so that we can fetch the details we want safely.

Requirements

Following are the requirements to build this app:

Python: We are building a Python app, so make sure you have Python installed in your system. If not, you can download it from here.

Selenium: After the installation of python, we next need to install selenium in our system. We can do so by using the following command through pip in the command prompt-

pip install selenium

Firefox browser: We have to make sure that we have Mozilla Firefox Browser installed in our system since the latest version of InstaPy dropped the support for chrome. Since InstaPy is Selenium based tool, it uses the browser to fetch the details.

Firefox WebDriver: After the installation of Firefox we have to make sure that we install the FireFox Webdriver for it, which you can find here. Choose the right version according to your system and install it.

InstaPy: Finally, here comes the main character! InstaPy is basically a tool that automates your social media interactions and is implemented in Python using the Selenium module. To know more about InstaPy, you can visit here.

You can download the InstaPy library using the following pip command:

pip install instapy

Now that we have all the requirements installed in our system, let's grab a cup of coffee and start coding!

Step 1: Firstly, we need a spare Instagram account.

There may be a risk of getting your account banned as we will be using this account as a bot😬. So don't use your main account's credentials here.

Step 2: If your main account is private, use your spare account to follow your main account.

This is so that the spare account has the access to the list of all the followers and following.

Step 3: Now, import instapy

And enter your spare account's username and password in the fields mentioned in the code. This code will open your Firefox browser and start a session. It will try to load the Instagram page and log in there with the username and password mentioned. The handling of the browser happens automatically using selenium, so there's no need to panic or manually interact with the browser.

Step 4: Grab the list of all the followers

And followings of your main account and store them in the different lists named followings and followers. In grab_following and grab_followers, there are two parameters.

In the first one, enter the username of your main account of whom you want to fetch the details and make sure to follow that account using your spare account if it is private.

In the second parameter, for grab_following, enter the number of followings of the main account, and for grab_followers, enter the number of followers of the main account.

Step 5: Now that you have scraped the list of followers and followings,

We just need to use the set difference and voilà! We have the list. To know about the user ids, we can simply print them using a for loop as shown in the code snippet below.

In the above code, we have also created a text file listing all the accounts who don't follow you back.

Here is the complete code for your reference.

Tip: After the completion of the program, close the Firefox browser's window before trying to rerun the program.

Now that you've got the list, don't forget to leave some claps and share the article with your enthusiastic friends. See you!




Continue Learning