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

210
Views
Why can't I scrape for specific information of this webpage? (with node.js and jQuery)

So I want to scrape for specific information about news from this website: https://24.hu/fn/gazdasag/2022/07/23/igy-lehet-olcsobb-a-maganorvos-az-egeszsegpenztarbol/

I'm working on creating a web crawler and I need the new's title and the content. I use node.js, javascript and jQurey. And I've also created tests for that and I can reach the title, but I can't get the context. Despite of the fact that I've tried the code in the console of the browser, and it works well there.

This would be the code in the console: $('[data-io-article-url="https://24.hu/fn/gazdasag/2022/07/23/igy-lehet-olcsobb-a-maganorvos-az-egeszsegpenztarbol/"]').text().trim();

And I get the following answer: `A pandémia az életünk számos területét befolyásolta, de talán semmit sem annyira közvetlenül, mint az orvoshoz járási szokásainkat. Az elmúlt két évben tanúi lehettünk annak, hogy a végletekig leterhelt állami egészségügyi rendszer egyre nehezebben bírja a betegek megfelelő ellátását. Ráadásul úgy tűnik, hogy a járványt még korántsem tudhatjuk magunk mögött..... In my VsCode I saved the html of the webpage and created the follolwing test:

const fs = require("fs");
const parser = require("../24Parser");

const newsPage1Html = fs.readFileSync("tests/html/test.html");

let parserResult;

beforeAll(() => {
    parserResult = parser(newsPage1Html, );
})

describe("parsing html news page correctly", () => {
    test("title", () => {
        expect(parserResult.title).toBe("Így lehet olcsóbb a magánorvos az egészségpénztárból");
    })
    test("content", () => {
         expect(parserResult.content).toBe("lskl");
    })
})

And my parser looks like this:

const cheerio = require("cheerio");

function parseAll(html, page) {
    const $ = cheerio.load(html);

    const title = $('[itemprop="headline"]').text().trim();
    
    //const content = $(`[data-io-article-url="${page}"]`).text().trim();
    const content = $('[data-io-article-url="https://24.hu/fn/gazdasag/2022/07/23/igy-lehet-olcsobb-a-maganorvos-az-egeszsegpenztarbol/"]').text().trim();

    return { title, content}
}

module.exports = parseAll;

So I use exactly the same code and I get nothing in case of the content. Why is that? I would like to create it dynamic later, that's why the commented line.

about 4 years ago · Santiago Trujillo
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!