Create an Instagram Bot using Python

Abishek Shyamsunder
Analytics Vidhya
Published in
4 min readAug 11, 2020

Instagram…., a platform used by millions to showcase their talents and make a mark in the ever changing virtual world. Ever wanted to make it your own???

I wrote a program of approximately 100 lines, that could automatically create a new instagram account within a minute. Follow along and you’ll be introduced to a world of new possibilities!!!

Let us start of with what we want our application to do

  1. Setup a temporary mail ID, that can be used to sign up to instagram
  2. Use the temporary mail ID, from which the first name, last name and user name can be extracted and enter this into the instagram signup page
  3. Automate movements of mouse and keyboard to enter the Birthday information
  4. Obtain the verification code from the inbox of the mail-id and submit

Thankfully, each of these steps have simple solutions that take minutes to implement using the powers of python!

Step 1

To setup a temporary mail id, I chose to use www.minuteinbox.com which provides us with a mail id and access to its inbox for 10 minutes.

I opened chrome, navigated to the webpage and extracted its page source using selenium, a tool that automates browsers.

Using BeautifulSoup4, I extracted the email Id assigned to us, using the tag name and its id.

Step 2

Using the email address, which was of the form xxx.yyy@outree.org, I extracted the First name and Last name. Using this, I set the username and password for the account as well

Once all this was ready, we submit these details to the webpage!

Submitting info via Python

Step 3

I found that, for entering the birthday information, the elements displayed in the web-page did not show up in the page source. So, I worked around this by using pyautogui which automates the mouse and keyboard. So I directly interacted with the open chrome tab

Mouse clicking specific points on the screen

Step 4

Finally, we wait a minute for the conformation code to arrive at our inbox, and again using the page source, extract it.

However because of the ethical ramifications of submitting this conformation code and creating a fake account, I stopped my code at this point!

In Conclusion

A mere 100 lines of python code enabled us to create a new instagram account from scratch!

Some of the things that we learnt are:

  1. Submitting information to a web-page (used for creating accounts, logging in etc.)
  2. Interacting with various elements on the screen using automation of mouse and keyboard (used for cases where a HTML oriented solution is not available, or difficult to implement, e.g. filling the date)
  3. Switch seamlessly between different http sessions, using information from one in another. (used for obtaining the conformation code from one web page and submitting it in another)

Technically, the knowledge that you gained from reading this post can be used to create any web application and virtually any process!

If you want to try implementing this code on your own, please do checkout my Github repo! All constructive criticism is welcome!

--

--