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

184
Visualizações
How come the difference between 'View page source' and document.querySelector("html").innerHTML?

I want to extract subtitles from this YouTube page (link).
I found timedtext, when looking via 'View page source'.

But not when I search via javascript console. It won't find it:

document.querySelector("html").innerHTML.match("timedtext")

But for this other YouTube page, it does actually work both.

How come the difference and how to fix it?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

As I commented, if you want to extract the subtitles using this way, consider instead search for the script tag that has the ytInitialData variable = that's the one that has the url of the timedtext.

I can't tell the difference, but, I assume the javascript code injects the HTML code once the page is loaded.

After pasting the line you share in your comment:

ytInitialPlayerResponse.captions.playerCaptionsTracklistRenderer.captionTracks

I got the timedtexts in the available languages. Keep in mind, though, probaly not all videos has auto-generated captions - example

In that example, I didn't get the captions, so, I don't think that inspecting the source code of the page works for all videos.

about 4 years ago · Juan Pablo Isaza Relatório
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