Introduction to Instaloader module in Python - GeeksforGeeks

19 Oct, 2021
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. 
 pip install instaloader
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:
instaloader –highlights geeks_for_geeks
Output:
The above command downloads public highlights of a particular profile
instaloader “#hashtag” coding_memes
Output:
The above command downloads posts having a given Hashtag.
instaloader –igtv geeks_for_geeks
Output:
The above command is used to download videos of a particular profile on instagram in .mp4 format.
Python3
import instaloader # Get instanceloader = instaloader.Instaloader() # Login using the credentialsloader.login(USER, PASSWORD) # Use Profile class to access metadata of accountprofile = instaloader.Profile.from_username(loader.context,                                            'geeks_for_geeks')
 It returns the number of accounts following the given account
Python3
# returns iterator to list of followers of given profilefollowers = profile.get_followers() for follower in followers:    print(follower)
Output:
It returns the number of accounts followed by given account
Python3
# returns iterator to list of followees# (followings) of given profilefollowees = profile.get_followees() for followee in followees:    print(followee)
Output:
Number of followees of this profile
It returns the total number of posts
Python3
# returns an integer representing number of postsmedia = profile.mediacount print(media)
Output:
Total number of media count
It returns the total number of igtv posts
Python3
# returns integer equal to the number of igtv postsigtv = profile.igtvcount print(igtv)
Output:
8
It  tells whether account is private or not
Python3
# returns a bool objectprivate = profile.is_private print(private)
Output:
False
It returns the description/ bio of the account
Python3
# returns bio of the profilebio = profile.biography print(bio)
Output:
Biography of this profile using biography attributes
It returns the link to the profile picture of the account
Python3
# returns link to the profile pictureprofile_pic = profile.profile_pic_url print(profile_pic)
Output:
Profile picture image ulr
It returns the external url (if any)
Python3
# returns external url if it is present in the profileurl = profile.external_url print(url)
Output:
External link through Instagram
It tells whether the account is a business account or not
Python3
# returns a bool objectbusiness = profile.is_business_account print(business)
Output:
True
It returns the type of business account is associated with
Python3
# returns the business categorybusiness_type = profile.business_category_name print(business_type)
Output:
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. 
saxenaanjali239
Packages
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Comments
Old Comments
How to Install PIP on Windows ?
How to drop one or multiple columns in Pandas Dataframe
How To Convert Python Dictionary To JSON?
Selecting rows in pandas DataFrame based on conditions
Check if element exists in list in Python
Defaultdict in Python
Python | Get unique values from a list
Python | os.path.join() method
Create a directory in Python
Python | Pandas dataframe.groupby()