Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda