How to bulk download video from instgram link using python scrapy

Here is a basic outline of how you can use the Scrapy framework to bulk download videos from Instagram:

  1. Install Scrapy by running pip install scrapy
  2. Create a new Scrapy project using the command scrapy startproject instagram_scraper
  3. Navigate to the project directory and create a new spider using the command scrapy genspider instagram_spider
  4. Edit the spider file (located at instagram_scraper/spiders/ to specify the links to the Instagram posts that you want to scrape. You can do this by setting the start_urls variable to a list of URLs.
  5. In the spider file, define the parse method to extract the video URLs from the HTML of the Instagram post page. You can use the xpath method of the Selector object to select elements from the HTML and the extract method to extract the video URL.
  6. In the spider file, define the download_video method to download the video using the urlretrieve function from the urllib module.
  7. In the main Scrapy script (located at instagram_scraper/, use the CrawlSpider class to crawl through the Instagram post pages and call the download_video method for each video.

Here is some example code to get you started:

import scrapy
from urllib.request import urlretrieve

class InstagramSpider(scrapy.Spider):
name = “instagram_spider”
start_urls = [

def parse(self, response):
video_url = response.xpath(‘//video/@src’).extract_first()

def download_video(self, video_url):
urlretrieve(video_url, “video.mp4”)

how to download video from instgram I hope this helps! Let me know if you have any questions.


Related Articles

Back to top button