0

I'd like to return a list of the presidents of the United States from the wikipedia api, but I can't seem to find an efficient way to do so.

I can use the rvsection param to isolate to that section of the content, but it seems like a very brittle (and still hard to parse) solution. Is there an easier way to get the names of the presidents in that section?

Current query:

https://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&pageids=19908980&rvsection=1
Nemo
  • 2,414
  • 2
  • 28
  • 59
Nick Tomlin
  • 27,264
  • 11
  • 59
  • 87

1 Answers1

1

For your particular case (extracting the list of the US presidents) there's even an example query in wikidata query service. Although it also returns the wife of the presidents. With a little modification you can get only presidents

Petr
  • 5,541
  • 2
  • 18
  • 24