Web scraping Instagram using Python
By Mehul Gupta
In this project, we will be web scraping data from Instagram user profiles using python for data analyzing
- Web scraping data from websites are an integral part of data science for making datasets and for data visualizations.
- To scrap Instagram, we have to install the Instaloader library using the pip command. Now after installing the library, we have to create an instance of Instaloader class
- Then we will load a profile from Instagram with the username(here I have taken Cristiano Ronaldo)
- Now we will print all the details attached to this Instagram account by applying the parameters of the Instaloader module. Data from the user profile can be useful for data analysis.

- The output for the user profile(Cristiano Ronaldo)are as follows

- Next, you can log in to your own profile using python for performing various methods that we will discuss after this
So you will enter your username and password in Bot.login() method and then you can log in on the terminal itself.
- Scraping Data for Followers and Followings of the user profile
- Scraping data from Instagram user profiles can help you in analyzing the data more closely and efficiently.
- We will create instances and start a for loop in profile.get_followers() and get_followees() method which will return the usernames of the users.
- We can also Download posts from other user profiles
- First, we will create an instance of a user with his/her username
- Then, we will apply the get_posts() method and iterate over a number of posts of their profile.
- We can download the posts using download.posts() method, it will save the post folder in a new directory that is created by the module itself
- You can fetch more data and insights to Instagram user profiles if you explore other methods and functions of the Instaloader library.
Comments