Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Download Instagram Reel using Python

  • Last Updated : 19 Nov, 2021

In this article, we will discuss how to download Instagram reel using Python.

Instagram is a social networking platform owned by Facebook. In Python, there are numbers of libraries available by which we can solve some real-life problems and it also provides some tools to scrape information from Instagram. One of the tools is Instascrape Python Package. Instascrape is the powerful Instagram data scrapping toolkit.  

Installation :

Install insta-scrape library from PyPI

pip install insta-scrape

To download reels from Instagram first import all the required libraries. In our example, we are importing the time module because while saving the file we will concatenate time with the filename to avoid naming conflict. Now add Session-Id and Headers. Session-Id is valid until you logged out. so when u will next time, again you need to pass a new session-id that time. ( You will get your session-id in Session Storage by Inspecting the page ). It is not that easy to scrape data directly due to updated policies of Instagram so we have to pass the session id into the headers. Using Reel Module and Providing Download Location we can get the job done.

Syntax:

insta_reel=Reel(‘instagram link’)

insta_reel.scrape(headers=headers)

insta_reel.download(download_path.mp4″)

By following the above procedure, you will get downloaded reel in your specified directory.   

Example: Download Instagram reels using Python

Python3




from instascrape import Reel
import time
 
# session id
SESSIONID = "Paste session Id Here"
 
# Header with session id
headers = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)\
    AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.74 \
    Safari/537.36 Edg/79.0.309.43",
    "cookie": f'sessionid={SESSIONID};'
}
 
# Passing Instagram reel link as argument in Reel Module
insta_reel = Reel(
 
# Using  scrape function and passing the headers
insta_reel.scrape(headers=headers)
 
# Giving path where we want to download reel to the
# download function
insta_reel.download(fp=f".\\Desktop\\reel{int(time.time())}.mp4")
 
# printing success Message
print('Downloaded Successfully.')

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!