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

474
Visualizações
Puppeteer: How get img src inside nested selector?

I have a structure like this:

<div class="loaded active">
<img class="full" src="img1.jpg">
</div>

<div class="loaded">
<img class="full" src="img2.jpg">
</div>

<div class="loaded">
<img class="full" src="img3.jpg">
</div>

I need get link of img1.jpg. I can get links for class="full":

const slkImg = '.full';
    
const imgs = await page.$$eval(slkImg, postLinks => postLinks.map(link => link.src));

but I don't know how do it for only img1.jpg.

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

0

As discussed in the comments,

page.$eval('.loaded.active .full', el => el.src)

works thanks to two things:

  1. Using $eval rather than $$eval to select one element
  2. Using .loaded.active .full to select the first .full descendent of the first .loading.active parent.
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