Instagram bot – posting images, auto like, and bulk follow

| |

Home » Instagram bot – posting images, auto like, and bulk follow

Instagram has become a platform that people use to connect and share their pictures, videos, and stories. People use Instagram for gaining popularity and for promoting their businesses as well as for marketing purposes. In today’s article, we will learn about the Instagram bot. We will be doing some tasks like posting pictures, auto liking, and bulk following using an Instagram bot. You can build this as a small project so that it will help you build big projects in the future.

What is an Instagram bot?

The Instagram bot is essentially a computer program that allows you to automate personal interactions across Instagram through the use of various features available to users on their mobile phones such as liking posts, making comments, answering polls, sending direct messages, and following new profiles.

How to create an Instagram bot:

Prerequisite:

To create a bot that could share content on Instagram we’ll be programming this in Python so make sure you have python already installed in your system and fortunately, there is a useful library called InstaBot that will make it easy.

InstaBot: Instabot is a Python library that implements an Instagram API wrapper, not only providing you with the ability to access Instagram’s service but also many other useful capabilities, such as following/unfollowing users by keyword sharing post, liking tags, or subscribing/unsubscribing from specific posts. Instabot is smart enough to know how to filter out people with whom it will subscribe to the list of users. 

Using this library we will do three tasks in this tutorial 

  1. How to post images to Instagram.
  2. How to bulk follow accounts.
  3. How to auto-like images related to tags.

The instabot library can be installed using the command in your command prompt/terminal:

pip3 install instabot

Note:- To get started, you will need your Instagram account ID and password for InstaBot. (email id and phone numbers do not work in this library)

How to post images to Instagram

from instabot import Bot
bot=Bot()
bot.login(username="manshirke",password="************")
bot.upload_photo("photo.jpg",caption="hello how are you #bot #rom")
Let’s break down and see what we did in the code step by step

Step 1:

from instabot import Bot

First, we imported the Bot class from the instabot library.

Step 2:

bot=Bot()

Second, we created a variable bot and this will store class BOT.

Step 3:

bot.login(username="manshirke",password="************")

In the third step, we created a login class and added the parameter username and password, you have to add here your own Instagram account’s user id and password in which you want to upload or post the images.

Step 4:

bot.upload_photo("photo.jpg",caption="hello how are you #bot #rom")

And lastly, we created the upload_photo class then in the first parameter we added the path of the photo that you want to upload and in the second parameter, we added the captions along with hashtags you can add anything you want here.

Output:

After you have completed everything and have just reviewed your work to make sure it was done properly, you can see in the output that the instabot will get you to log in to your Instagram account first, and then it will upload the post and now you can go on Instagram and check the post that we uploaded – along with the captions you wrote down earlier. this process will take a few minutes for everything to finish. So please wait patiently as this process is running.

Note: – Every time you run the code a folder named config will generate automatically in your main python file directory. If you want to run the code again you must delete this folder first then re-run your program.

How to bulk follow accounts

from instabot import Bot
bot=Bot()
bot.login(username="manshirke",password="***********")

bot.follow_followers('geekyhumans',nfollows=10)
Let’s break down and see what we did in the code, first, second and third steps are the same as before that contains importing the library, adding bot class, and adding log in credentials you can get that reference in the first topic.
bot.follow_followers('geekyhumans',nfollows=10)

Let’s call our follow_followers class that will follow the followers of a specific Instagram account that you added in the string formate, and in the followers’ parameter, you can add how many accounts you want to follow. as an example, I am providing my Instagram handle now what this command will do is it will follow the 10 followers of my Instagram account.

Output:

In this part also review your work to make sure it was done properly and you have completed everything after that you can see in the output that the instabot will get you to log in to your Instagram account first, and then it will start going through Instagram account and getting all the user id and start following them one by one. this process will also take a few minutes for everything to finish. So please wait patiently as this process is running.

from instabot import Bot
bot.login(username="manshirke",password="***********")
tags=['python','bot','coding']
for i in tags:
    bot.like_hashtag(i,amount=10)
Let’s break down and see what we did in the code, first, second and third steps are the same as before that contains importing the library, adding bot class, and adding log in credentials you can get that reference in the first topic.

Step 4:

tags=['python','bot','coding']

Let’s say you want to like a post, but the post is on two different hashtags. Let’s say “#funny” and “#bot”. Using tag variables, you can combine all of those hashtags into one tag variable and like the post with just one process.

Step 5:

for i in tags:
    bot.like_hashtag(i,amount=10)

Here we created for loop that will trade on hashtags that you added earlier and after that, we added the bot.like_hastag function and in that function, we added parameter amount with the value of 10. This is the number of posts that the bot will automatically like in each hashtag that you added.

Output:

In this part also review your work to make sure it was done properly and you have completed everything, that you can see in the output that the instabot will get you to log in to your Instagram account first, and then it will start going through Instagram and finding the post that has the hashtags that you provided and started liking the posts. this process will also take a few minutes for everything to finish even more time than uploading the photo. So please wait patiently as this process is running.

Final Words

Instagram is the topmost social media, where users have a tendency of exploring different types of automation. Making an Instagram bot is not a big deal. You can easily create an Instagram bot with the help of any programming language. For the ease of the users, we have gone with python and the instabot library. It’s very easy and simple to use the instabot library and create an Instagram bot as we saw earlier in the tutorial.

Here are some useful tutorials that you can read:

Spread the love
 
   
Previous

Monitor Python scripts using Prometheus

Create APIs using gRPC in Python

Next

Leave a Comment