Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

124
Views
When webscraping a youtube page a video returns and empty object but video.src returns a value

I tried executing the code below twice, first time I tried to return the vid from the p.evaluate function, it returned an empty object. The second time I tried returning the vid.src from the same function and it returned blob:https://www.youtube.com/2e29a76f-f87b-4ebc-85a3-faa1ad671e3d. How can an empty object preserve a value and if its not empty why does it appear so when trying to return it on its own? I need the video itself and not the link in order to convert in into a utf-8 format so I cant just use the source of it.

The code returning the video:

const p = require("puppeteer");

const func = async () => {
  const browser = await p.launch({ headless: true, slowMo: 10 });
  const page = await browser.newPage();
  await page.goto("https://www.youtube.com/watch?v=dXjKh66BR2U");
  await page.waitForSelector(".html5-main-video");
  const vid = await page.evaluate(() => {
    const vid = document.querySelector(".html5-main-video");
    return vid;
  });
  console.log(vid);
  await browser.close();
};

func();

The code returning the src:

const p = require("puppeteer");

const func = async () => {
  const browser = await p.launch({ headless: true, slowMo: 10 });
  const page = await browser.newPage();
  await page.goto("https://www.youtube.com/watch?v=dXjKh66BR2U");
  await page.waitForSelector(".html5-main-video");
  const vid = await page.evaluate(() => {
    const vid = document.querySelector(".html5-main-video");
    return vid.src;
  });
  console.log(vid);
  await browser.close();
};

func();

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!