Hiya
Solution:
To start with, we will import necessary libraries in our python script such as Pandas, Beautiful Soup, Requests, and Selenium. These libraries will help us in scraping the data from Instagram and storing it in a structured pandas table. We will also be using a WebDriver program for Selenium to interact with the Instagram webpage.
Once the libraries are imported, we will define a function that takes the username of the Instagram account as input. This function will then use the Requests library to get the HTML page of the user’s profile. We will pass the URL in the get method of Requests, along with the user’s username as a parameter.
Next, we will use Beautiful Soup to convert the HTML page into a simpler and more readable format. We will use this object to navigate and extract the required data from the page. Using Beautiful Soup, we can find and extract information such as the user’s profile name, bio, followers, following, number of posts, and profile picture URL.
To access the user’s Instagram posts, we will use the Selenium library. We will launch the Instagram page with the desired username using a WebDriver program and then scroll through the page programmatically to retrieve all the posts. This will help us in gathering public URLs to access the user's creative easily.
As the Selenium program scrolls down the page, we will use Beautiful Soup to extract post information such as the post URL, the number of likes, comments, and the post's caption. We will then store this information in a structured pandas table.
Finally, we will export the pandas table to a CSV file for future reference. The CSV file will contain information about the user's profile, including the number of followers, following, posts, and URLs to access each post, along with their creative content.
This script can be used multiple times with different Instagram usernames to gather data and store them in separate CSV files. This way, we can create a vast database of Instagram profiles with their relevant information.
In conclusion, the python script we have developed can help in gathering publicly available information from specified Instagram accounts and storing the data in a structured pandas table quickly. It also allows the user to access the user's creative through public URLs created by the script. The CSV file can be used for data analysis, marketing, or any other relevant purposes.
Best regards,
Giáp Văn Hưng