Insu — Instagram Bot.

Making of INSU Part 1

What is Insu?
Well, Insu is an Instagram bot that can like posts using hashtags using python.

Why Insu?
This is a good question little bit hard to answer, I know there are many other Instagram bot which is more efficient and have more functions than Insu. Well, you are right Insu isn’t the best bot available online and yes many bots which can be found on GitHub has more features than Insu. But the fact is 90% of the bots don’t work quite well and the rest who works (I think) require more knowledge and time to make it off use and they all are complex. The problem is not with the bots, they are made with tons of fabulous plugins and APIs which provides the best experience but throughout the time these APIs get older, they don’t support new versions of Instagram and doesn’t work properly on other python versions. I have explored many bots I failed to use any of them properly.

Well, the only point of making this bot is to have something which I can easily use and also for fun because it is like an adventure because I have used a different method to approach the same goal.

So, let’s start.

We will be using the hard way to make this bot, This bot will work in all versions from Python 3.6 to 3.10.
First of all, these are the plugins we will use are:-

Time (import time)
PyAutoGui (import pysutogui as pg)
PyFiglet (from pyfiglet import Figlet)

So you have to use pip or if you are using IDE then you can install them by mouse clicks but do make sure you are installing them in the right interpreter.

And if you have noticed pyautogui then i think you have got an idea of how we will be proceeding. So have fun.

Step 1. Imports:-

import time
import pyautogui as pg
from pyfiglet import Figlet

Figlet is an optional import I have used this to make it look cooler.

f = Figlet(font='doom')
#screensize = pyautogui.size()
print("----------------(Insu(v0.5) Instagram Bot by likenull)-------------------")

The above is just for decoration kind of stuff.

Step 2. Pyfiglet.

Before writing code to automate Instagram likes using python we have to first check our screen size.

To do this we will use:-

screensize = pg.size()

This code will give you info about what is your screen size. This code is temporary after step 2 we have to delete all code written in step 2.

For my case it shows
Size(width=1366, height=768)

Now we have to manually input code and data using which pyautogui can use Instagram to like posts. It is a lengthy process but this is all worth it after we have completed this.

So we have to know what are the points where we have to click to open the post. to do that we will use pyautogui another code that will provide us with the coordinates of our mouse pointer.

position = pg.position()

This code will help us to get the position of the mouse pointer.
Now we will note where we have to click on the Instagram website to get to the post which we have to like.

For this, we have to split screens one of browser with Instagram opened and the other with our code.
And then we have to put our mouse pointer where we have to click. like this.

As you can see in the second image it gives us the location of what will be the position of the mouse if we click on the search bar in split-screen mode.

And in main code, we will write, 98)

This means it has to click on the search bar button which in my case (width= 1366 and height=768) is 236, 98.

And using the position code we have to get info where we have to click and when.

For me:-
Step 1 is to click on the search bar which is at 236, 98.

Step 2 is to write the hashtag, which we will ask the user to input while running our code(insu)., 98)

Step 3 we have to go “down” in search bar preferences regarding our search and we will use the pause function to let Instagram show what we want to search.

pg.PAUSE = 3.25'down')

Step 4 Now we have to press enter 2 times to browse the posts with our hashtags.

pg.PAUSE = 2.0'enter')'enter')

here we will use double enter.

Step5. Now we have to scroll for the recent post which includes all posts and the above are popular posts, It is on us where we want to continue to like the popular post or the recent ones, for me I want to target people with fewer likes on the post so that if I liked their posts then in return they will at least visit my profile.

pg.PAUSE = 3.6'pagedown')

Step6. Now we have to click on the post to start liking it, using our old method we will get the location where we have to click on it to get our post. For me, it is on 98, 518 which means it will open the first post to like.

pg.PAUSE = 2.0, 518)

Step7. Now when the post is opened then we have to move our pointer in the middle of the post for that we have to get the location and then we have to apply the code.
for me, it is on 322, 400

pg.moveTo(332, 400)

Step8. Now we have to use double click to like the post.

pg.Pause = 2.0
pg.doubleClick(332, 400)

Now, this will like the post and we also have to use the press right arrow for the next post to be liked. we also have to create a new loop to do this automatically. And we also have to get input from the user on how many posts to like and which hashtags to use. So for now this is it in the next post there will be complete code with a full explanation. Proper code will work and automatically like the amount of posts users want will also show progress.

Click here to read Part 2>

Originally Published at by codelikenull.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store


Breathing in the world of nothingness just like you. If you are writer then please check out this writer survey