Ayushi Rawat
Ayushi Rawat's Blog

Ayushi Rawat's Blog

Download Display Picture of an Instagram Account Using Python

Download Display Picture of an Instagram Account Using Python

Ayushi Rawat
·Nov 28, 2020·

6 min read

Subscribe to my newsletter and never miss my upcoming articles

Listen to this article

Hello world!

I am attending a Technical Writing Bootcamp at @hashnode. Hashnode Bootcamp II is a free virtual Bootcamp to help beginner technical writers to improve their writing skill. This article is inspired by the latest session by Anna McDougall, [@AnnaJMcDougall]

TASK: In 7 days, write a blog post from one of the topics you learned during the session

In this Blog article, I will share my thoughts on the same. Let's get started.

Have you heard about Instagram? Do you Use Instagram? Well, In this Blog article, we will learn how to Download Display Picture of an Instagram Account. We will see the implementation in Python.

Check out the Repository for Ultimate Resource in python. Drop a star if you find it useful! Got anything to add? Open a PR on the same!

You can refer to my YouTube video Tutorial to see a working tutorial for better Understanding and a step by step Guide of the same.

What will be covered in this Blog

1. Instagram Introduction
2. Instaloader Introduction
3. How to Download Display Picture of an Instagram Account

Instagram Introduction:

I do not think Instagram needs an Introduction but for those who do not know, Instagram is an photo and video sharing social networking platform owned by Facebook. If you wish to know more about Instagram, you can refer its Wikipedia page.

Instagram Link: instagram.com

Instaloader Introduction:

The Instaloader module is python package having great functionalities to scrap instagram, it’s functions can be used as command line utility. It can be used for download pictures (or videos) along with their captions and other metadata from Instagram.

Key Features of Instaloader:

  • downloads public and private profiles, hashtags, user stories, feeds and saved media,
  • downloads comments, geotags and captions of each post,
  • automatically detects profile name changes and renames the target directory accordingly,
  • allows fine-grained customization of filters and where to store downloaded media,
  • automatically resumes previously-interrupted download iterations.

If you wish to know more about it, you can refer to Instaloader Documentation. Use this link to navigate to the documentation.

Now that you are aware of Instaloader basics, we can move forward to the coding section. Let's get started!

Time to Code!

You can find all the code at my GitHub Repository. Drop a star if you find it useful.

code.png

In order to access the Python library, you need to install it into your Python environment, use the following command to install Instaloader

pip install instaloader

Now, let's import the package in our Python script and create an instance test

import instaloader

test = instaloader.Instaloader()

Once done, let's take user input to get the username of the account you wish to download the profile picture ! I am storing it in acc

acc = input('Enter the Account Username: ')

#acc = 'leomessi'

So here, Assuming you all must have heard the name of Lionel Messi, we have entered the account username as leomessi.

Finally, its time to download the data.

We will make use of download_profile method here and pass in two parameters:

  • acc: the username
  • profile_pic_only: we will set this to be True.
test.download_profile(acc, profile_pic_only = True)

A new folder will be created with the account username, in our case, leomessi and it will contain the Display Picture.

2018-10-23_13-55-58_UTC_profile_pic.jpg

Let's have a look at the output. It will look something like this:

ezgif.com-gif-maker.gif

This is how you can Download Display Picture of an Instagram Account using python script. That's it!

Simple, isn't it? Hope this tutorial has helped. I would strongly recommend you to Check out the YouTube video of the same and don't forget to subscribe my Channel.

You can play around with the Instaloader library and even explore more features. You can even make use of Python GUI using Tkinter.

You can find all the code at my GitHub Repository. Drop a star if you find it useful.

Thank you for reading, I would love to connect with you at Twitter | LinkedIn.

Do share your valuable suggestions, I appreciate your honest feedback!

You should definitely check out my other Blogs:

Resources:

See you in my next Blog article, Take care!!

Did you find this article valuable?

Support Ayushi Rawat by becoming a sponsor. Any amount is appreciated!

See recent sponsors Learn more about Hashnode Sponsors