Scrape Instagram using Instagramy in Python

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 analyze the data using Pandas.

Installation

The python package Instagramy is used to scrape the Instagram quick and easy. This package is installed by running the following command. Based on network connection it scrapes the data for you.

pip install instagramy

Example 1: Scraping basic details

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

from instagramy import Instagram
  
  
# Connecting the profile
user = Instagram("geeks_for_geeks")
  
# printing the basic details like
# followers, following, bio
print(user.is_verified())
print(user.popularity())
print(user.get_biography())
  
# return list of dicts
posts = user.get_posts_details()
  
print('\n\nLikes', 'Comments')
for post in posts:
    likes = post["likes"]
    comments = post["comment"]
    print(likes,comments)

chevron_right


Output:



Example 2: Analysing the data

Python3

filter_none

edit
close

play_arrow

link
brightness_4
code

from instagramy import Instalysis
  
# Instagram user_id of ipl teams
teams = ["chennaiipl", "mumbaiindians",
         "royalchallengersbangalore", "kkriders",
         "delhicapitals", "sunrisershyd"
         "kxipofficial"]
  
data = Instalysis(teams)
  
# return the dataframe
data_frame = data.analyis()
data_frame

chevron_right


Output:


Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course.




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.