All posts

Download Instagram reels by scraping using NodeJS.

An overview of my 2023 walkthrough for extracting an Instagram reel’s video URL with Puppeteer and Cheerio.

Node.jsPuppeteerCheerio

The original approach combines browser rendering with HTML parsing. Puppeteer runs the page’s JavaScript; Cheerio reads the resulting markup.

Render the page

Install the two packages, launch a headless browser, and navigate to the reel. Wait for the video element before reading the HTML with page.content(). A simple HTTP request misses the video element when it is added by JavaScript.

npm · Dependencies
npm install puppeteer cheerio

Extract the video URL

Load the rendered HTML into Cheerio, find the video element, and read its src attribute. The result is the direct video URL. Close the page and browser after collecting the HTML.

JavaScript · Read the video source
const $ = cheerio.load(html);
const videoDirectLink = $('video').attr('src');