Let’s use instascrape to download Instagram video reels with python code. Instagram Reels are short video posts that appear along side regular image posts on instagram profiles. We will be using Python 3.8.10 for this example. Let’s go! ✨🔥⚡
UPDATE (Jan 9, 2023): THIS CODE MAY NO LONGER WORK AS EXPECTED DUE TO CHANGES IN INSTAGRAM. TRY INSTALOADER AS AN ALTERNATIVE. INSTALOADER ALLOWS YOU TO DOWNLOAD THE ENTIRE PROFILE EASILY.
First let’s install the instascrape library. We can install it with the following code at command line:
pip install insta-scrape
Here is our full code:
#Example reel: https://www.instagram.com/reel/Cccgd2MFCs4/
from instascrape import Reel
import os
import time
sample_reel = Reel('https://www.instagram.com/reel/Cccgd2MFCs4/')
sample_reel.scrape()
reeldir = os.getcwd()
sample_reel.download(fp=f"{reeldir}\\reel{int(time.time())}.mp4")
print(dir)
print(f"This reel has {sample_reel.video_view_count:,} views.")
Let’s explain what is happening here:
- We import the Reel method from the instascrape library as well as os and time libraries which we will use to customize the file name of the downloaded file.
- We define the scraper for the instagram reel, sample_reel. We call the method Reel and supply the URL of the reel to be downloaded. Usually the reel URL can be found by clicking the kebab menu icon (3 horizontal or vertical dots) and clicking “copy link” in the menu that pops up.
- We call the method on our reel object, scrape() which returns a scrape instance.
- The variable reeldir simply stores the directory path of the current script, which is the path we will save our reel to.
- The download() method simply downloads the reel as an mp4 video to the path reeldir and the current time is appended to the filename. The path is given as parameter fp .
- The directory of the new file and the file name are printed to the screen along with the view count of the saved reel.
If all goes well, when the above code executes you should have new MP4 video file in the same file path as your python script.
We hope this tutorial on how to download instagram reels with Python helped. Good luck! 👌👌👌
Are you worried about your child’s online safety or your employees’ productivity? Do you wonder what they’re accessing on their devices? SentryPC is here to address these concerns. This all-in-one, cloud-based software provides robust activity monitoring, content filtering, and time management, making it ideal for both parental control and employee monitoring. Embrace peace of mind and enhanced efficiency with SentryPC, the proactive solution to your digital monitoring needs. CLICK HERE to get started.