How to parse information from a given Wikipedia article

504 views Asked by At

So, I was making this website that takes date from the user and returns all the historical events that happened on this day.

The natural choice was to use information from the Wikipedia. Consider for example this article: https://en.wikipedia.org/wiki/June_23 There is an 'Events' section there, that has it's own id '#Events', so it wouldn't be a problem to find all the necessary information.

So, is it possible to create a new document (using JS), then parse all the information I need and include it on my own page?

If anyone interested that is the website: http://www.boykodev.com/sites/day-in-history/ I have used an 'iframe' to display the Wikipedia article.

1

There are 1 answers

2
guergana On BEST ANSWER

This is done with an API.

If you know how to manipulate JSON data you can extract whatever you want from the document.

This is the JSON data from the document you want: https://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=June_23&rvprop=timestamp|user|comment|content

Check this on how to interpret the data: https://en.wikipedia.org/w/api.php?action=help&modules=main