Automate Instagram Image Downloads with Puppeteer and Node.js, follow the rabbit

Automate Instagram Image Downloads with Puppeteer and Node.js, follow the rabbit

In today's digital age, social media platforms like Instagram have become treasure troves of visual content. Whether you're a marketer, a researcher, or just someone looking to collect beautiful images, being able to automate the download of images from Instagram can be incredibly useful. In this blog post, we'll walk you through a step-by-step guide on how to scrape Instagram images using Puppeteer in Node.js.

Why Puppeteer?

Puppeteer is a Node.js library that provides a high-level API to control Chrome or Chromium over the DevTools Protocol. It can be used for web scraping, automating tasks, and much more. Here’s why Puppeteer is the tool of choice for this task:

  • Headless Browsing: Puppeteer can run Chrome in headless mode, making it efficient and fast for scraping tasks.
  • Full Control: With Puppeteer, you have complete control over the browser, allowing you to interact with web pages as a real user would.
  • Easy to Use: Puppeteer’s API is straightforward and well-documented, making it easy to get started.

Getting Started


Before diving in, ensure you have the following installed on your system:

  • Node.js (v12.0.0 or higher)
  • npm (v6.0.0 or higher)

Step 1: Setup Your Project

First, create a new directory for your project and navigate into it. Initialize a new Node.js project:

mkdir instagram-scraper
cd instagram-scraper
npm init -y

Next, install Puppeteer:

npm install puppeteer

Step 2: Create the Configuration File

Create a config.json file to store the Instagram usernames you want to scrape:

    "usernames": [

Replace "username1", "username2", and "username3" with the actual Instagram usernames.

Step 3: Write the Scraper Script

Create a file named instagram-scraper.js and add the following code:

Download de code in Github:

Step 4: Run the Script

With everything set up, simply run your script with Node.js:

node instagram-scraper.js

The script will navigate to each specified user's Instagram profile, scroll through their feed to load all images, download the images, and save them in a directory named after the username. Additionally, a JSON file (instagram-images.json) will be created in each user's directory, containing the image filenames and the download date.


Automating the download of Instagram images can save you a significant amount of time and effort. With Puppeteer and Node.js, this task becomes straightforward and efficient. Feel free to expand and customize the script to fit your specific needs. Happy scraping!