How To Make Instagram Bot Accounts
Build The Best Free Instagram Automation Bot 15 Minutes
Edit August 2021: The last major open source Instagram bot was shut down in April 2020, since they used the Instagram API(which was detectable). Outsourcing to manual people in other countries also doesn’t work, since Instargam admitted in a security blog in 2017 that they keep a history of the network vs. account. This is why schools, with hundreds per IP, never get blocked, but new proxies or outsourced manual interaction instantly does. This tutorial is left for educational purposes, since it works to learn how to setup quick cloud servers. Instoo works, since it runs on your home network using a chrome extension. (I built Instoo) coding experience necessary. This guide shows you how to automate instagram likes, follows, and comments across 25 accounts for free in minutes. You can use this for easy guerrilla marketing, growing your small business from cold start on auto-pilot, or for spreading any other message. I’ve combined all the best bots you can build here to grow up to 50–200 followers per day. I’ve included three bots. and Instabot you build yourself, so it’s a bit more complicated, but you learn how to easily use cloud servers to run bots. is an easier to use chrome extension installed in your browser with a graphical instructions:1. Setup Google Cloud AccountHead on over to Google Cloud, and sign up for a trial account. You get $300 free for a year for every new account. You can delete the account anytime to avoid being charged after a year. Click on the menu, and navigate to Compute Engine and VM instancesOpen VM instances in Google cloud console2. Create Cloud InstanceClick “Create Instance, ” which is a server in the cloud, and fill out the details like in the image Cloud Server InstanceMicro instance,. 6gb memory, and Ubuntu 18. 04 LTS are the important settings. This will deduct $5 from your trial every a Ubuntu 18. 04 instance3. Connect To InstanceOnce the instance status is green in the dashboard, click “ssh” will open a new window like below that connects to the server:Use ssh to connect to the serverThis is what’s called a Linux shell in a server, but don’t worry it’s not hard to use. This is just like your Windows or Mac PC at home, but more functional for coding in the cloud(you can even make look like Windows if you wanted to). 4. Install InstabotFirst, install the bot by typing this into the Linux shell window, or pasting it in(CTRL+V)(wget plus that URL is all one line):sudo apt-get updatesudo aptsudo python3 -m pip install instabot-pywget enter after you paste in the last line. 5. Run the bot! Finally, run the bot using the command below, but replace USERNAME, PASSWORD, and PROXY with your real Instagram username, password, and the proxy you got in the last step. Don’t include the “” in the proxy address, but do include the username and thon3 USERNAME PASSWORD PROXYThe bot will start automating. Once you confirm it logs in and works, close it so you can edit the settings. 6. Edit SettingsNext edit by pasting in the line below:sudo nano will open the file for editing in the terminal(keyboard only, no mouse). Don’t change the username, password, or proxy parameters. Keep the comas, quotations, and other punctuation where it is, and just edit the setting like they’re originally formatted. Avoid changing the frequency of things, as these are determined empirically to avoid instagram the settings like login detailsWhen you’re done, hold “ctrl + x” to exit, and hit “y” to accept changes, then “y” again to save changes under the same file name. You can see what’s going on with saving/exiting at the bottom of the screen in the nano text editor. After you’re done, re-run the bot using this command again:python3 USERNAME PASSWORD PROXYInstabot is an open source bot that underpins many commercial bots you find online. These style of bots are now getting detected by instagram, but they still work for some users with high trust levels. This bot emulates a phone, so it also allows auto-welcome messages and scheduled posts, but browser emulation works better now for auto-liking/stabot Step-by-Step instructions:1. Install InstabotFirst, install the python pip package installer by typing this into the Linux shell window, or pasting it in(CTRL+V):sudo apt-get update && sudo apt-get install python-pip -y && sudo apt-get install git -yYou can install and download the bot by pasting the code lines below into the Linux Shell window. This will grab open source code from to install your bot. You can copy+paste all the lines at once, or type it into the window line-by-line, and just wait 2 minutes for it to finish installing. Hold CTRL+V to paste it in the Google cloud Linux shell install -U instabotgit clone –recursivecd instabot/examplesPress enter after you paste in the last line. Run the bot! You can run up to two bots per proxy. The examples folder has many different kinds of bots you can run, and I’ll explain how to use one of them here. Type “ls” in the Linux shell window to see all of a brand new Instagram account to test the bot works and does what you want first. Just paste the line below into the window(replace USERNAME, PASSWORD, and PROXY_ADDRESS to your login info and the proxy you got) and watch your little bot go:):python -u USERNAME -p PASSWORD dogsofinstagramThis script likes photos from all the followers of the “dogsofinstagram” account. You can change the last parameter to any account to do the same. There are many different scripts to automate different things like welcome_messages when people follow you. Feel free to ask how they ’ll see it start to follow/like/comment like below! The next bot is easier to use with buttons, and runs in your home browser so it always looks like a regular instagram uses browser emulation to run a bot in your browser, so it always looks like a user on your home network without needing proxies. This bot doesn’t require your login details in like other services, because it automates your logged in account at from the wnload the Instoo Google chrome extension at mClick the little circular icon in your chrome browser to open the bot:This will open the startup screen like below. Either open a new Instagram tab or go to the one it the Instagram tab finishes loading, log in to your account. If you’re already logged in, just switch back to the extension hashtags and accounts which are most relevant to your brand or niche. Don’t worry you can change them you’re a new or small account, keep things to under 400 per day. Instagram won’t detect you as a suspicious bot, but they still have usage limits for ALL users even regular people just clicking on the browser. If you have ever encountered this throttling, you know it goes away after a day. You still keep using Instagram like normal, but your likes/follows will stop registering after a certain number per day(400 for new accounts) can increase this limit by about 20 per week safely. The highest limit you can reach is 1000/ can now easily start automation by switching the follow/unfollow/likes switches to green:You’ll start to see the progress almost immediately:That’s it! You can leave the bot running forever and you won’t get banned. You still have to leave your browser and PC running, but this is much safer than giving your password to a website or getting flagged by instagram for using just built an Instagram bot in a cloud server using open source software! You can stop here, or go further with some tricks. Instagram bans these bots if use the same IP for many bots, or do too much at once. You can grow a bot farm to thousands using proxies…. After a year, or when you’re done, simply stop and delete the instances in the Google cloud these tricks to get the most of it:Age: Older/larger accounts can increase their automation speed to 1000+/day. Accounts under 21 days old without phone verification have a low bar to get detected. Accounts over 2–6 months old almost never get caught unless they blatantly violate the Avoid identical links in your bio across multiple accounts. It gets flagged as spam. If you must link to the same site, use different domains that oxies: Instagram proxies make your bot look like regular Instagram users, rather than a google cloud server IP address, by routing your traffic through servers around the world. Don’t run more than 2 bots per proxy(because Instagram detects them all at once). You can grow bot farms to the thousands using proxies for on google cloud. Instproxies has the cheapest Instagram proxies I can find, and their customer support is Farms: Each bot can send hundreds of people per day back to your business. If you use many bots, you multiply that traffic across different target audiences. This effect compounds over time as users follow and like your photos, and spreads even ttings: Slow bots are less likely to get banned. Keep things to under 400/day. Don’t auto-comment. This is less effective than likes. Liking content makes it hard to detect bots, since anyone could like at any time, and people end up following you back or checking out your profile. After you’ve grown your account for a few months to look like a regular Instagram, it becomes impossible to detect. This is also true for “grandfathered” accounts that are old. You can also buy PVA(phone verified) aged accounts online, but I can’t recommend any since they’re all ntions: Create “satellite” accounts to avoid Instagram bans, and create a network in various side-niches that forward traffic to your main account through mentions “@main_account_to_mention”. You can grow a bot network of thousands of accounts that each grow in different crowds and feed traffic to your main account, all for nearly free on fluencers can sell posts for more depending on their follower count and nicheA/B Testing Your Bot: You can optimize your bot for optimal growth by A/B testing different hashtags, comments, user targets, and content. Setup a test by changing one thing in your bot per week, and measure the engagement on Instagram. Avoid changing multiple things, which is called multivariate testing, because it only works well if you have a lot of traffic like facebook or google. If you improve engagement, keep the change. If you don’t, go back and try another change. Over many iterations of these micro-improvements, you can optimize your bots and Instagram accounts to grow thousands of followers per week. Through A/B testing you can grow your revenue even faster over short link analyticsHow you use this is up to you. You can populate the accounts with photos before you start botting to spread a message or grow followers for a brand. You can also grow “satellite” Instagrams that mention your main ones to feed traffic and followers to it, and the satellites can be in varied specific niches to test your ad me on Medium for more neat tutorials. Good luck, and feel free to ask questions! I always respond.
How to Make an Instagram Bot With Python and InstaPy
What do SocialCaptain, Kicksta, Instavast, and many other companies have in common? They all help you reach a greater audience, gain more followers, and get more likes on Instagram while you hardly lift a finger. They do it all through automation, and people pay them a good deal of money for it. But you can do the same thing—for free—using InstaPy!
In this tutorial, you’ll learn how to build a bot with Python and InstaPy, a library by Tim Großmann which automates your Instagram activities so that you gain more followers and likes with minimal manual input. Along the way, you’ll learn about browser automation with Selenium and the Page Object Pattern, which together serve as the basis for InstaPy.
In this tutorial, you’ll learn:
How Instagram bots work
How to automate a browser with Selenium
How to use the Page Object Pattern for better readability and testability
How to build an Instagram bot with InstaPy
You’ll begin by learning how Instagram bots work before you build one.
How Instagram Bots Work
How can an automation script gain you more followers and likes? Before answering this question, think about how an actual person gains more followers and likes.
They do it by being consistently active on the platform. They post often, follow other people, and like and leave comments on other people’s posts. Bots work exactly the same way: They follow, like, and comment on a consistent basis according to the criteria you set.
The better the criteria you set, the better your results will be. You want to make sure you’re targeting the right groups because the people your bot interacts with on Instagram will be more likely to interact with your content.
For example, if you’re selling women’s clothing on Instagram, then you can instruct your bot to like, comment on, and follow mostly women or profiles whose posts include hashtags such as #beauty, #fashion, or #clothes. This makes it more likely that your target audience will notice your profile, follow you back, and start interacting with your posts.
How does it work on the technical side, though? You can’t use the Instagram Developer API since it is fairly limited for this purpose. Enter browser automation. It works in the following way:
You serve it your credentials.
You set the criteria for who to follow, what comments to leave, and which type of posts to like.
Your bot opens a browser, types in on the address bar, logs in with your credentials, and starts doing the things you instructed it to do.
Next, you’ll build the initial version of your Instagram bot, which will automatically log in to your profile. Note that you won’t use InstaPy just yet.
How to Automate a Browser
For this version of your Instagram bot, you’ll be using Selenium, which is the tool that InstaPy uses under the hood.
First, install Selenium. During installation, make sure you also install the Firefox WebDriver since the latest version of InstaPy dropped support for Chrome. This also means that you need the Firefox browser installed on your computer.
Now, create a Python file and write the following code in it:
1from time import sleep
2from selenium import webdriver
4browser = refox()
Run the code and you’ll see that a Firefox browser opens and directs you to the Instagram login page. Here’s a line-by-line breakdown of the code:
Lines 1 and 2 import sleep and webdriver.
Line 4 initializes the Firefox driver and sets it to browser.
Line 6 types on the address bar and hits Enter.
Line 8 waits for five seconds so you can see the result. Otherwise, it would close the browser instantly.
Line 10 closes the browser.
This is the Selenium version of Hello, World. Now you’re ready to add the code that logs in to your Instagram profile. But first, think about how you would log in to your profile manually. You would do the following:
Go to Click the login link.
Enter your credentials.
Hit the login button.
The first step is already done by the code above. Now change it so that it clicks on the login link on the Instagram home page:
9login_link = nd_element_by_xpath(“//a[text()=’Log in’]”)
Note the highlighted lines:
Line 5 sets five seconds of waiting time. If Selenium can’t find an element, then it waits for five seconds to allow everything to load and tries again.
Line 9 finds the element whose text is equal to Log in. It does this using XPath, but there are a few other methods you could use.
Line 10 clicks on the found element for the login link.
Run the script and you’ll see your script in action. It will open the browser, go to Instagram, and click on the login link to go to the login page.
On the login page, there are three important elements:
The username input
The password input
The login button
Next, change the script so that it finds those elements, enters your credentials, and clicks on the login button:
14username_input = nd_element_by_css_selector(“input[name=’username’]”)
15password_input = nd_element_by_css_selector(“input[name=’password’]”)
20login_button = nd_element_by_xpath(“//button[@type=’submit’]”)
Here’s a breakdown of the changes:
Line 12 sleeps for two seconds to allow the page to load.
Lines 14 and 15 find username and password inputs by CSS. You could use any other method that you prefer.
Lines 17 and 18 type your username and password in their respective inputs. Don’t forget to fill in
Line 20 finds the login button by XPath.
Line 21 clicks on the login button.
Run the script and you’ll be automatically logged in to to your Instagram profile.
You’re off to a good start with your Instagram bot. If you were to continue writing this script, then the rest would look very similar. You would find the posts that you like by scrolling down your feed, find the like button by CSS, click on it, find the comments section, leave a comment, and continue.
The good news is that all of those steps can be handled by InstaPy. But before you jump into using Instapy, there is one other thing that you should know about to better understand how InstaPy works: the Page Object Pattern.
How to Use the Page Object Pattern
Now that you’ve written the login code, how would you write a test for it? It would look something like the following:
username_input = nd_element_by_css_selector(“input[name=’username’]”)
password_input = nd_element_by_css_selector(“input[name=’password’]”)
login_button = nd_element_by_xpath(“//button[@type=’submit’]”)
errors = nd_elements_by_css_selector(‘#error_message’)
assert len(errors) == 0
Can you see what’s wrong with this code? It doesn’t follow the DRY principle. That is, the code is duplicated in both the application and the test code.
Duplicating code is especially bad in this context because Selenium code is dependent on UI elements, and UI elements tend to change. When they do change, you want to update your code in one place. That’s where the Page Object Pattern comes in.
With this pattern, you create page object classes for the most important pages or fragments that provide interfaces that are straightforward to program to and that hide the underlying widgetry in the window. With this in mind, you can rewrite the code above and create a HomePage class and a LoginPage class:
from time import sleep
def __init__(self, browser):
owser = browser
def login(self, username, password):
The code is the same except that the home page and the login page are represented as classes. The classes encapsulate the mechanics required to find and manipulate the data in the UI. That is, there are methods and accessors that allow the software to do anything a human can.
One other thing to note is that when you navigate to another page using a page object, it returns a page object for the new page. Note the returned value of go_to_log_in_page(). If you had another class called FeedPage, then login() of the LoginPage class would return an instance of that: return FeedPage().
Here’s how you can put the Page Object Pattern to use:
from selenium import webdriver
browser = refox()
home_page = HomePage(browser)
login_page = home_page. go_to_login_page()
It looks much better, and the test above can now be rewritten to look like this:
With these changes, you won’t have to touch your tests if something changes in the UI.
For more information on the Page Object Pattern, refer to the official documentation and to Martin Fowler’s article.
Now that you’re familiar with both Selenium and the Page Object Pattern, you’ll feel right at home with InstaPy. You’ll build a basic bot with it next.
How to Build an Instagram Bot With InstaPy
In this section, you’ll use InstaPy to build an Instagram bot that will automatically like, follow, and comment on different posts. First, you’ll need to install InstaPy:
$ python3 -m pip install instapy
This will install instapy in your system.
Now you can rewrite the code above with InstaPy so that you can compare the two options. First, create another Python file and put the following code in it:
from instapy import InstaPy
Replace the username and password with yours, run the script, and voilà! With just one line of code, you achieved the same result.
Even though your results are the same, you can see that the behavior isn’t exactly the same. In addition to simply logging in to your profile, InstaPy does some other things, such as checking your internet connection and the status of the Instagram servers. This can be observed directly on the browser or in the logs:
INFO [2019-12-17 22:03:19] [username] — Connection Checklist [1/3] (Internet Connection Status)
INFO [2019-12-17 22:03:20] [username] – Internet Connection Status: ok
INFO [2019-12-17 22:03:20] [username] – Current IP is “17. 283. 46. 379” and it’s from “Germany/DE”
INFO [2019-12-17 22:03:20] [username] — Connection Checklist [2/3] (Instagram Server Status)
INFO [2019-12-17 22:03:26] [username] – Instagram WebSite Status: Currently Up
Pretty good for one line of code, isn’t it? Now it’s time to make the script do more interesting things than just logging in.
For the purpose of this example, assume that your profile is all about cars, and that your bot is intended to interact with the profiles of people who are also interested in cars.
First, you can like some posts that are tagged #bmw or #mercedes using like_by_tags():
1from instapy import InstaPy
3session = InstaPy(username=”
ke_by_tags([“bmw”, “mercedes”], amount=5)
Here, you gave the method a list of tags to like and the number of posts to like for each given tag. In this case, you instructed it to like ten posts, five for each of the two tags. But take a look at what happens after you run the script:
INFO [2019-12-17 22:15:58] [username] Tag [1/2]
INFO [2019-12-17 22:15:58] [username] –> b’bmw’
INFO [2019-12-17 22:16:07] [username] desired amount: 14 | top posts [disabled]: 9 | possible posts: 43726739
INFO [2019-12-17 22:16:13] [username] Like# [1/14]
INFO [2019-12-17 22:16:13] [username] INFO [2019-12-17 22:16:15] [username] Image from: b’mattyproduction’
INFO [2019-12-17 22:16:15] [username] Link: b”
INFO [2019-12-17 22:16:15] [username] Description: b’Mal etwas anderes \xf0\x9f\x91\x80\xe2\x98\xba\xef\xb8\x8f Bald ist das komplette Video auf YouTube zu finden (n\xc3\xa4here Infos werden folgen). Vielen Dank an @patrick_jwki @thehuthlife und @christic_ f\xc3\xbcr das bereitstellen der Autos \xf0\x9f\x94\xa5\xf0\x9f\x98\x8d#carporn#cars#tuning#bagged#bmw#m2#m2competition#focusrs#ford#mk3#e92#m3#panasonic#cinematic#gh5s#dji#roninm#adobe#videography#music#bimmer#fordperformance#night#shooting#’
INFO [2019-12-17 22:16:15] [username] Location: b’K\xc3\xb6ln, Germany’
INFO [2019-12-17 22:16:51] [username] –> Image Liked!
INFO [2019-12-17 22:16:56] [username] –> Not commented
INFO [2019-12-17 22:16:57] [username] –> Not following
INFO [2019-12-17 22:16:58] [username] Like# [2/14]
INFO [2019-12-17 22:16:58] [username] INFO [2019-12-17 22:17:01] [username] Image from: b’davs0′
INFO [2019-12-17 22:17:01] [username] Link: b”
INFO [2019-12-17 22:17:01] [username] Description: b’Someone said cloud? \xf0\x9f\xa4\x94\xf0\x9f\xa4\xad\xf0\x9f\x98\x88 \xe2\x80\xa2\n\xe2\x80\xa2\n\xe2\x80\xa2\n\xe2\x80\xa2\n#bmw #bmwrepost #bmwm4 #bmwm4gts #f82 #bmwmrepost #bmwmsport #bmwmperformance #bmwmpower #bmwm4cs #austinyellow #davs0 #mpower_official #bmw_world_ua #bimmerworld #bmwfans #bmwfamily #bimmers #bmwpost #ultimatedrivingmachine #bmwgang #m3f80 #m5f90 #m4f82 #bmwmafia #bmwcrew #bmwlifestyle’
INFO [2019-12-17 22:17:34] [username] –> Image Liked!
INFO [2019-12-17 22:17:37] [username] –> Not commented
INFO [2019-12-17 22:17:38] [username] –> Not following
By default, InstaPy will like the first nine top posts in addition to your amount value. In this case, that brings the total number of likes per tag to fourteen (nine top posts plus the five you specified in amount).
Also note that InstaPy logs every action it takes. As you can see above, it mentions which post it liked as well as its link, description, location, and whether the bot commented on the post or followed the author.
You may have noticed that there are delays after almost every action. That’s by design. It prevents your profile from getting banned on Instagram.
Now, you probably don’t want your bot liking inappropriate posts. To prevent that from happening, you can use set_dont_like():
session = InstaPy(username=”
With this change, posts that have the words naked or nsfw in their descriptions won’t be liked. You can flag any other words that you want your bot to avoid.
Next, you can tell the bot to not only like the posts but also to follow some of the authors of those posts. You can do that with set_do_follow():
If you run the script now, then the bot will follow fifty percent of the users whose posts it liked. As usual, every action will be logged.
You can also leave some comments on the posts. There are two things that you need to do. First, enable commenting with set_do_comment():
Next, tell the bot what comments to leave with set_comments():
t_comments([“Nice! “, “Sweet! “, “Beautiful:heart_eyes:”])
Run the script and the bot will leave one of those three comments on half the posts that it interacts with.
Now that you’re done with the basic settings, it’s a good idea to end the session with end():
This will close the browser, save the logs, and prepare a report that you can see in the console output.
Additional Features in InstaPy
InstaPy is a sizable project that has a lot of thoroughly documented features. The good news is that if you’re feeling comfortable with the features you used above, then the rest should feel pretty similar. This section will outline some of the more useful features of InstaPy.
You can’t scrape Instagram all day, every day. The service will quickly notice that you’re running a bot and will ban some of its actions. That’s why it’s a good idea to set quotas on some of your bot’s actions. Take the following for example:
t_quota_supervisor(enabled=True, peak_comments_daily=240, peak_comments_hourly=21)
The bot will keep commenting until it reaches its hourly and daily limits. It will resume commenting after the quota period has passed.
This feature allows you to run your bot without the GUI of the browser. This is super useful if you want to deploy your bot to a server where you may not have or need the graphical interface. It’s also less CPU intensive, so it improves performance. You can use it like so:
session = InstaPy(username=’test’, password=’test’, headless_browser=True)
Note that you set this flag when you initialize the InstaPy object.
Using AI to Analyze Posts
Earlier you saw how to ignore posts that contain inappropriate words in their descriptions. What if the description is good but the image itself is inappropriate? You can integrate your InstaPy bot with ClarifAI, which offers image and video recognition services:
Now your bot won’t like or comment on any image that ClarifAI considers NSFW. You get 5, 000 free API-calls per month.
It’s often a waste of time to interact with posts by people who have a lot of followers. In such cases, it’s a good idea to set some relationship bounds so that your bot doesn’t waste your precious computing resources:
With this, your bot won’t interact with posts by users who have more than 8, 500 followers.
For many more features and configurations in InstaPy, check out the documentation.
InstaPy allows you to automate your Instagram activities with minimal fuss and effort. It’s a very flexible tool with a lot of useful features.
In this tutorial, you learned:
How to use the Page Object Pattern to make your code more maintainable and testable
How to use InstaPy to build a basic Instagram bot
Read the InstaPy documentation and experiment with your bot a little bit. Soon you’ll start getting new followers and likes with a minimal amount of effort. I gained a few new followers myself while writing this tutorial. If you prefer video tutorials, there is also a Udemy course by the creator of InstaPy Tim Großmann.
If there’s anything you’d like to ask or share, then please reach out in the comments below.
Make an Instagram Bot in 5 Minutes | by c0d3x27 | Dev Genius