Reputation: 99
I would like to get infobox section from Wikipedia. I tried to use the Wikipedia API but the response is very complex:
https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&rvsection=0&titles=Cristiano_Ronaldo&format=json
I need for example to extract only date of birth
parameter. Is it possible?
Upvotes: 3
Views: 1758
Reputation: 7036
In your example, you need date of birth for Cristiano Ronaldo, but this Wikipedia article is associated with Wikidata Item Q11571. This item usually include the most of Wikipedia Infobox parameters (as Property:P569 - date of birth).
So, for your case it is better idea to use Wikidata API:
https://www.wikidata.org/w/api.php?action=wbgetentities&sites=enwiki&props=claims&titles=Cristiano_Ronaldo
The response include the date of birth under property P569, and a lot of other information as place of birth, image, sex, official website, country, etc:
...
"P569": [{
"mainsnak": {
"datavalue": {
"value": {
"time": "+1985-02-05T00:00:00Z",
...
Upvotes: 4