Skip to content

Latest commit

 

History

History
89 lines (53 loc) · 2.56 KB

README.md

File metadata and controls

89 lines (53 loc) · 2.56 KB

Instagram logo

Instagram Scraper


🤖 This script scrapes instagram post of your favorite public accounts.

📝 Table of Contents

🧐 About

This script basically scrapes images from the publicly available instagram account's posts and stores them in a folder with proper naming.

Instagram credentials need to be provided in the environmental variables along with the account username to be scraped.

For Example:
Images are stored in the format : USERNAME-COUNTER-POSTED_DATE.jpg

Instagram Account : RanveerSingh

Output : ./PATH/RanveerSingh/RanveerSingh-1-21-May-2021.jpg

💭 How it works

The scraper first opens instagram login page on an Incognito Chromium tab and enters the credentials specified in the environmental variables.

Then it searches for the account using the username provided, it opens the top account shown in the result box.

If the account does not have any posts or if the account is private we get an error message on console.

  "NO POSTS AVAILABLE"

The 12 recent images from post are downloaded in respective folder and are named according to their date.

The entire script is written in NodeJS (JavaScript)

🎈 Usage

To use the scraper:

First we need to install all the dependencies

  npm install

Before running the script, we have to create an .env file with credentials and username.

INSTAGRAM_USERNAME = your_username
INSTAGRAM_PASSWORD = your_password
INSTAGRAM_ACCOUNT = account_to_scrape

To run the script.

npm run dev (or) node index.js

⛏️ Built Using

  • Node.js - Node.js, an asynchronous event-driven JavaScript runtime
  • Puppeteer - Puppeteer, a Node library which provides a high-level API to control Chrome or Chromium
  • fs - Node.js file system module allows you to work with the file system on your computer
  • dotenv - Dotenv loads environment variables from a .env file into process.env

😄 Developed only for learning purpose. Could use API for better results !