Skip to main content

Command Palette

Search for a command to run...

How to Make Instagram automation tool

In 50 Line of code Interesting right! We are going to make this tool using Node.js

Published
5 min read
How to Make Instagram automation tool

So Now Let’s start,

Before we start we are going to use the Library, there are many libraries but while I was learning I got to know about Puppeteer . Which has cool documentation and a good explanation of how to use it in our code.

Now, what puppeteer can do:

Most things that you can do manually in the browser can be done using Puppeteer! Here are a few examples to get you started:

  • Generate screenshots and PDFs of pages.

  • Crawl a SPA (Single-Page Application) and generate pre-rendered content (i.e. "SSR" (Server-Side Rendering)).

  • Automate form submission, UI testing, keyboard input, etc.

  • Create an up-to-date, automated testing environment. Run your tests directly in the latest version of Chrome using the latest JavaScript and browser features.

  • Capture a timeline trace of your site to help diagnose performance issues.

  • Test Chrome Extensions.

So Hope the above Info helps to Know about the library.

Experience: While working on this project I got the opportunity to learn node.js and puppeteer. Using this we can do so many things as mentioned above.

Problem: There is also Problem I face while Working Like browser Run in the background Coz puppeteer has set headless default false so to see the browser we have to make it true. Also while going to the next page URL is also changed to handle we also have to wait. So after all Making mistakes and reading documentation again I solve all problems.

Demo Of Project

Go to this Link %[https://www.awesomescreenshot.com/video/3201740?key=3708eac96ab77405f80cd2e1b0abe8a5]

GitHub Link: %[https://github.com/Priyanshu-official/Automation-tools]

So Let’s code

Step 01

So first we download Node.js To check it install or not, use this command carbon.png

Step 02

Now create Index.js file And do

npm init -y

Now let’s install puppeteer

carbon (1).png

Step 03

first, we import the file carbon (2).png

And we use the JSON file to enter our id pass to login in file

  • Create config.json and put your details in there

carbon (4).png

  • Link file to index file

carbon (3).png

So now we are going to launch the browser before that I suggest you read the documentation of puppeteer.

Step 04

To explain I you better I have added proper comment so you can follow to

carbon (6).png

Step 05

Now we can see the browser so let’s code to enter our id pass carbon (7).png

  • Delay: It helps to slow the speed of automation so you can see what going on.
  • waitForSelector: it helps to load the page and then enter details.

Now here We are going to automate the Like button we take Input no of post you want to like.

Step 06

So now we log in to page, Now Search person carbon (8).png

Here you can see

  • [placeholder=’search’] This find a place to input username.
  • waitforSelector(“".-qQT3 ._7UhW9"”)This is a class I Have use google console to get this class.

console.png

Step 07

Now You will see the Person Profile page, Now we go to the first post and open it

carbon (9).png

Step 08

So let's Like first Post carbon (10).png

congo.png

Now to go Next post

carbon (11).png

Now We want to Like No of post at Once so We use Loop to repeat Step 08

carbon (12).png

  • To Take input from User

carbon (13).png

Now let's close browser

carbon (14).png

Thanks to these great resources