Download Instagram profile pic using Python
Instagram is a photo and video-sharing social networking service owned by Facebook, Python provides powerful tools for web scraping of Instagram.
Modules required and Installation:
pip install requests
For a given user profile, open view-source and find “profile_pic_url_hd” . To find press ctrl+f and type “profile_pic_url_hd” the link with it is our data or profile pic.
The link will look like :
Below is the stepwise implementation of the project:
Step 1: import all dependence
Step 2: Ask for username and send a response to Instagram.
Step 3: if the response is ok, find profile photo link
(Note: replace ‘\\u0026’ with ‘&’ in the string_url to remove bad URL timestamp or bad URL hash error)
Step 4: Now, create a loop and download photo.
Other Method :
We can download profile pic of any Instagram account using instaloader module by just giving Instagram handle of the user.
First we need to install instaloader module :
pip install instaloader
Output : Profile pic will be downloaded in the the same directory when we enter the input user id.
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. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course