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

252
Vistas
How to get the infobox data of Wikipedia?

I am making a website that will automatically get the data from wikipedia using Wikipedia API. What I have already tries is to use find('.infobox') to find the infobox data.

However, I only want to get the data below the horizontal line in the infobox(starting from disease: covid in the photo below)

Here is the code I currently had:

let area = "Canada"
var url="http://en.wikipedia.org/w/api.php?action=parse&format=json&page=COVID-19_pandemic_in_"+area +"&redirects&prop=text&callback=?";
$.getJSON(url,function(data){
     wikiHTML = data.parse.text["*"];
$wikiDOM = $("<document>"+wikiHTML+"</document>");
var info= $wikiDOM.find('.infobox').html();
console.log(info)

This will display all the information in the infobox.

Could anyone give me an idea or a solution that tell me how to do that?

Also, the image from wikipedia will not be able to display which will show error of invalid url (the image area will display alt text) Is there a way to choose not to display image before displaying which will prevent the image (alt text) and error in console ?

Thanks for any responds!

*In the image below, I only want to get the data from disease: Covid-19 to Vaccinations

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

The solution is to filter element depending on the conditions.

I only want to get the data from disease: Covid-19 to Vaccinations

You can look at the element that encloses these information and find things in common. I see each element includes th.infobox-label.

Check if other element does not have the same structure.

If not, filtering the element by whether the element includes th.infobox-label will work out.

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