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,441
  • 2
  • 29
  • 63
Nick Tomlin
  • 28,402
  • 11
  • 61
  • 90

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,999
  • 2
  • 19
  • 25