Introduction to Instaloader module in Python - GeeksforGeeks (2024)

Improve

The Instaloader module is a Python package having great functionalities to scrap instagram, it’s functions can be used as command-line utility. The Instaloader key is used to download:

  • Posts of public/private account
  • stories
  • IGTV
  • Comments on post
  • Profile information
  • Story highlights

The instaloader module can be used to download everything of profile/Instagram user, you need to interrupt by CONTROL+C to kill the process. However, for downloading files of a private account, you must log in, there is no compulsion for a public account. Also, comments are in json file which is zipped as a folder.

Installation:

 pip install instaloader

Implementation:

Download everything about a profile:

instaloader geeks_for_geeks

On using this command your program will download everything about profiles. For public account, it will download stories, post, highlights news. For private, it only downloads profile photo and other public information about profile.

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (1)

Download highlights of a particular profile:

instaloader –highlights geeks_for_geeks

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (2)

The above command downloads public highlights of a particular profile

Download through Hashtag:

instaloader “#hashtag” coding_memes

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (3)

The above command downloads posts having a given Hashtag.

Download IGTV videos

instaloader –igtv geeks_for_geeks

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (4)

The above command is used to download videos of a particular profile on instagram in .mp4 format.

Profile class can be used to access metadata of profile

Python3

import instaloader

# Get instance

loader = instaloader.Instaloader()

# Login using the credentials

loader.login(USER, PASSWORD)

# Use Profile class to access metadata of account

profile = instaloader.Profile.from_username(loader.context,

'geeks_for_geeks')

Attributes of Profile class:

followers

It returns the number of accounts following the given account

Python3

# returns iterator to list of followers of given profile

followers = profile.get_followers()

for follower in followers:

print(follower)

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (5)

followees

It returns the number of accounts followed by given account

Python3

# returns iterator to list of followees

# (followings) of given profile

followees = profile.get_followees()

for followee in followees:

print(followee)

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (6)

Number of followees of this profile

mediacount

It returns the total number of posts

Python3

# returns an integer representing number of posts

media = profile.mediacount

print(media)

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (7)

Total number of media count

igtvcount

It returns the total number of igtv posts

Python3

# returns integer equal to the number of igtv posts

igtv = profile.igtvcount

print(igtv)

Output:

8

is_private

It tells whether account is private or not

Python3

# returns a bool object

private = profile.is_private

print(private)

Output:

False

biography

It returns the description/ bio of the account

Python3

# returns bio of the profile

bio = profile.biography

print(bio)

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (8)

Biography of this profile using biography attributes

profile_pic_url

It returns the link to the profile picture of the account

Python3

# returns link to the profile picture

profile_pic = profile.profile_pic_url

print(profile_pic)

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (9)

Profile picture image url

external_url

It returns the external url (if any)

Python3

# returns external url if it is present in the profile

url = profile.external_url

print(url)

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (10)

External link through Instagram

is_business_account

It tells whether the account is a business account or not

Python3

# returns a bool object

business = profile.is_business_account

print(business)

Output:

True

business_category_name

It returns the type of business account is associated with

Python3

# returns the business category

business_type = profile.business_category_name

print(business_type)

Output:

Introduction to Instaloader module in Python - GeeksforGeeks (11)

Business category name of this profile

NOTE : Profile class objects have many more properties and functions to scrap Instagram profile metadata. A list of all the properties and functions of the Profile class object can be obtained using dir() function.



Last Updated : 27 Jan, 2023

Like Article

Save Article

Share your thoughts in the comments

Please Login to comment...

Introduction to Instaloader module in Python - GeeksforGeeks (2024)

FAQs

How to install Instaloader module in Python? ›

To install Instaloader,
  1. Ensure that you have Python, at least version 3.8, and pip installed.
  2. Then, install Instaloader using: pip3 install instaloader.

Is Python instaloader safe? ›

Is instaloader safe to use? The python package instaloader was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as safe to use.

Does Instaloader work on private profiles? ›

Instaloader can login to Instagram. This allows downloading private profiles. To login, pass the --login option.

How does Instaloader work? ›

The instaloader module can be used to download everything of profile/Instagram user, you need to interrupt by CONTROL+C to kill the process. However, for downloading files of a private account, you must log in, there is no compulsion for a public account. Also, comments are in json file which is zipped as a folder.

What is instaloader in Python? ›

Instaloader is a tool to download pictures (or videos) along with their captions and other metadata from Instagram. With Python installed, do: $ pip3 install instaloader $ instaloader profile [profile ...]

How to install module from Python? ›

Install Modules with pip
  1. Ensure the pip module is already installed. ...
  2. Verify the release of pip to ensure it is installed correctly. ...
  3. Install the new Python module using the command pip install <module-name> . ...
  4. To list all installed Python modules and packages, use the pip list command.
Jan 28, 2022

Is Instaloader an API? ›

Instaloader exposes its internally used methods and structures as a Python module, making it a powerful and intuitive Python API for Instagram, allowing to further customize obtaining media and metadata.

Where does Instaloader save files? ›

Instaloader saves the session file to ~/.config/instaloader/session-YOUR-USERNAME . See --sessionfile option for how to override this path.

Can Python be trusted? ›

Like any programming language, Python is only as secure as the code that is written in it. Properly written Python code can be secure, but code that is not written securely can leave your application vulnerable to security risks.

Can jobs see your private Instagram? ›

An employer can still ask you to view your social media accounts. But if you use a private account, it means they can't check up on you without your knowledge.

What is instapy? ›

Tooling that automates your social media interactions to “farm” Likes, Comments, and Followers on Instagram Implemented in Python using the Selenium module.

Is Instagram algorithm real? ›

The Instagram algorithm is a set of rules that ranks content on the platform. It decides what content shows up and in what order, all across the app (users' feeds, the Explore Page, the Reels feed, hashtag pages, etc.).

How to fetch data from Instagram using Python? ›

To set up the Instagram data fetching tool, you need to import the Instaloader Python library and create an instance of the Instaloader class. After that, you need to provide the Instagram handle of the profile from which you want to extract the data.

How does Instagram collect my data? ›

Analytics information: We use third-party analytics tools to help us measure traffic and usage trends for the Service. These tools collect information sent by your device or our Service, including the web pages you visit, add- ons, and other information that assists us in improving the Service.

How to install logger module in Python? ›

You don't need to install anything to get started with Python logging because the Python standard library includes a logging module. Simply import the logging module to use the module in your script.

How to install pip in Python? ›

Follow the steps below to install PIP using this method.
  1. Step 1: Download PIP get-pip.py. Before installing PIP, download the get-pip.py file. ...
  2. Step 2: Installing PIP on Windows. To install PIP, run the following Python command: python get-pip.py. ...
  3. Step 3: Verify Installation. ...
  4. Step 4: Add Pip to Path. ...
  5. Step 5: Configuration.
Nov 30, 2023

How do I add an instaloader to my path? ›

You will need to find the folder where it was installed and add that to your path. If you use a virtual environment, this should happen automatically when you activate the environment.

How to install Python module in command line? ›

On Windows, to install a module named module_name open a Command Prompt window and run:
  1. pip install --user module_name. ...
  2. pip3 install --user module_name. ...
  3. python -m pip install --user module_name. ...
  4. python3 -m pip install --user module_name. ...
  5. import sys, os; os.system(sys.executable + ' -m pip install --user module_name')
Jan 11, 2021

Top Articles
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 6848

Rating: 4.2 / 5 (63 voted)

Reviews: 86% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.