Download Instagram profile picture in Python
Hello friends, in this tutorial I will tell you how you can download Instagram profile pictures using Python.
Download Instagram profile picture in Python
For this task, I have used the instaloader
package, which is a third-party module built for Python. First, open your command prompt in Windows or Terminal for macOS/ Linux and execute the following command.
Install dependency
pip install instaloader
Import instaloader
Once installed, import it to your code to enable its usage.
import instaloader
Download profile picture
I have created an object for the Instaloader() class and stored it in a temporary variable, insta_obj
. Now I have declared a string variable profile_name
and assigned it a value. Here I have assigned it a value of amitabhbachan__1942, you can assign any value as per your wish.
Code :
insta_obj = instaloader.Instaloader() profile_name = "amitabhbachan__1942" insta_obj.download_profile(profile_name, profile_pic_only=True)
I have then used the download_profile()
function. This function takes the profile name as well as some other attributes, like download_stories_only, download_tagged, post_filter, etc as input. In my case, I want to download only the profile picture so I have assigned the attribute profile_pic_only as True and provided the profile_name as arguments.
Output:
Now you can successfully download anyone’s Instagram profile picture in Python.
Leave a Reply