Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

205
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda