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

169
Visualizações
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 à 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