1

I'm trying to get "Table" content of a page by wiki api query:

the "Table-Content" is block content numbered as 3

I tried this query, but it doesn't work

http://en.wikipedia.org/w/api.php?action=query&prop=revisions&format=json&rvprop=content&rvlimit=10&rvparse=1&rvsection=1&rvsection=2&titles=Ha%20Noi&redirects=

BTW, How can I get 2 very first section, instead of only one section with query like this Thanks

2

If you want to get the table of contents, or, in other words, the list of sections of a page, you can use action=parse&prop=sections:

http://en.wikipedia.org/w/api.php?action=parse&format=json&prop=sections&page=Ha%20Noi&redirects

| improve this answer | |
  • Thank you so much svick. – tungcan Jan 17 '14 at 16:39
  • what can I do if I want to get contents from section 4? – Gowtham Gopalakrishnan May 20 '14 at 8:40
3

If you want to get contents from a specific section you have to add &section=4 , like this:

https://en.wikipedia.org/w/api.php?action=parse&format=json&prop=sections&page=Ha%20Noi&redirects&section=4
| improve this answer | |
  • i'm able to get section details from above api by passing section index. but it returning html text . I want to get only plain text. how can i get it ? – Harshal Bhatt Nov 7 '17 at 4:21
  • You can get the result in format json or format xml. Not plain text as described in official wiki – tmac12 Nov 7 '17 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.