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

147
Visualizações
Find every src value in a webpage that contains certain text javascript

I want to find and "console.log" every src value in an HTML page that has a certain text; for example (dam/etc/vsvs). Is it possible to do it with javascript and in the console, as I'm not able to reach to source code of the page? I'm not a developer just trying to find the images I want and list them.

Any help will be appreciated.

Thanks in advance.

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

0

As far as I understand, you have an HTML page and you need to grab every src value which meets some expectations (i.e. starts with smth, includes smth).

So, if you are able to run a script on the page then you can recursively go node by node and check if it has an src attribute.

const findSrc = (node) => {
  const attributesToCheck = ['src', 'srcset', 'data-srcset']

  const srcs = attributesToCheck.map(name => {
    const attr = node.getAttribute(name)

    // here is a condition for your match
    return attr?.startsWith("/etc") ? attr : false
  }).filter(Boolean)

  if (node.children) {
    return srcs.concat(Array.from(node.children).flatMap(findSrc));
  }

  return srcs;
};

console.log(findSrc(document.body));
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