In this article, we will learn how can we get Instagram profile details using web scraping. Python provides powerful tools for web scraping, we will be using Instagramy here. This tool is specifically made for Instagram and also analyzes the data using Pandas.
Installation
The python package Instagramy is used to scrape Instagram quick and easily. This package is installed by running the following command. Based on the network connection it scrapes the data for you.
pip install instagramy
Example 1: Scraping basic details
Python3
from instagramy import InstagramUserÂ
Â
# Connecting the profileuser = InstagramUser("Lazyroar_for_Lazyroar")Â
# printing the basic details like# followers, following, bioprint(user.is_verified())print(user.popularity())print(user.get_biography())Â
# return list of dictsposts = user.get_posts_details()Â
print('\n\nLikes', 'Comments')for post in posts:Â Â Â Â likes = post["likes"]Â Â Â Â comments = post["comment"]Â Â Â Â print(likes,comments) |
Output:
Example 2: Analysing the data
Python3
from instagramy import InstalysisÂ
# Instagram user_id of ipl teamsteams = ["chennaiipl", "mumbaiindians",         "royalchallengersbangalore", "kkriders",         "delhicapitals", "sunrisershyd",         "kxipofficial"]Â
data = Instalysis(teams)Â
# return the dataframedata_frame = data.analysis()data_frame |
Output:

