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

165
Vistas
How to automatically download an image from YouTube frontend with no file extension in src field? (JavaScript)

For my research, I use JavaScript to download data of the top YouTube comments that are shown to a user, that is why I am using data from the YouTube frontend and not the YouTube API. Apart from comment text, number of likes, etc. I would also like to store the profile pictures of the people leaving comments. The img tag looks like this:

<img id="img" class="style-scope yt-img-shadow" alt="name" height="40" width="40"
src="https://yt3.ggpht.com/ytc/AKedOLSXk4DiR7nlvyuGiByOeaJmg4pH8Yt2FAqoVy73YQ=s48-c-k-c0x00ffffff-no-rj">

The problem that I am experiencing is that the src attribute does not have an extension at the end, so when I am trying to download a .jpg image with the code listed below, the image is just opened in a new tab and the link from the src attribute is saved as a .jpg file, which is not interpreted correctly. I also tried adding an extension like .png or .jpg at the end of the link, but it didn't work.

function downloadImage(imageSrc) {
  const link = document.createElement('a')
  link.href = imageSrc
  link.download = 'image.jpg'
  document.body.appendChild(link)
  link.click()
  document.body.removeChild(link)
}

The solutions that I found so far:

  1. Save Image file from Image URL javascript html

  2. How to view the full background image of a YouTube channel?

Unfortunately, they don't consider the case with no extension in the src attribute when the images should be saved automatically with JavaScript.

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