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

133
Views
Cheerio cant get info

I am trying to build an API for my homework. API is supposed to get info from HTML tag <a>. I need its href and text. It works for some parts of the website, for some it doesn't.

I gave the correct url, so that is not the problem. Also I can't get an error from terminal, or browser.

I inspected 2 element from 2 sites , first one works second doesn't.

This is the one I can read and get

<a href="/oto-bahce-yapi/goodyear-175-65-r14-82h-eagle-sport-2-yaz-lastigi-uretim-tarihi-7-hafta-2022/" class="name-price" title="Goodyear 175/65 R14 82H Eagle Sport 2 Yaz Lastiği  (Üretim Tarihi: 7.Hafta 2022)" tabindex="0">

and this is the one I cant read

<a href="/market/indo-mie-noodle-paket-jumbo-sebzeli-120-g/" class="name-price" title="Indo Mie Noodle Paket Jumbo Sebzeli 120 g" rel="bookmark">

In return of second one i get an empty array, first one works fine

Part of my code

const urunler = [];

marketler.forEach((market) => {
  axios.get(market.adress).then((response) => {
    const html = response.data;
    const $ = cheerio.load(html);

    $('a[class="name-price"]', html).each(function () {
      const urunadi = $(this).text();
      const url = $(this).attr("href");

      urunler.push({
        urunadi,
        url: market.base + url, //if need a base
        kaynak: market.name,
      });
    });
  });
});

What do you think is the problem or solution?

about 4 years ago · Juan Pablo Isaza
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!