How to save web page content as mp4 using puppeteer in nodejs

  javascript, node.js, puppeteer

Is there a way to download mp4 or video files using puppeteer?
Here’s an example of what I want to download https://www.w3schools.com/html/mov_bbb.mp4

Here’s my script so far

async downloadVideo(link = '') {
    try {
        this.browser = await puppeteer.launch({
            headless: false,
            args: ['--no-sandbox']
        })

        this.page = await this.browser.newPage();

        if (!link) {
            throw new Error(`No link provided, process skipped`);
        }

        await this.page.goto(link, { waitUntil: 'load', timeout: 60000 })

    }
    catch (error) {
        throw error;
    }
}

Source: Ask Javascript Questions

LEAVE A COMMENT