Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

128
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda