Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!