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

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

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 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!