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

154
Visualizações
Cheerio get method not working as expected

I am doing some web scraping in JS for the first time and already stuck.

I have a cheerio object that contains div tags I want to pull out. If I iterate through the cheerio using the each method, I can see they are all there

temp.each(function (i, e) {
    console.log($(e).text());
    console.log("...looping");
    console.log(i);
 });

              
...looping
0
“The square root of the amount of ducks I give"
...looping
1
Sweet Home, Alabama
...looping
2
FOOTER GOES HERE
...looping
3

I see that quote I want is under the element indexed at 1, but if I try to grab it with temp.get(1).text(), I get TypeError: temp.get(...).text is not a function.

There is something big I am missing here.

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

0

.get gives you the element, not the Cheerio object - elements don't have a .text method. Either use the proper property to extract text from an element:

console.log($(e).get(1).textContent)

Or use .eq instead, which will give you a Cheerio object containing only the element at that index.

console.log($(e).eq(1).text())
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