I want to fetch complete data of https://en.wikipedia.org/wiki/Cat. I have tried different way using wiki api but i am not able to fetch data in Json. I am only able to fetch cat first description. Is there any way to fetch complete page content in Json format?
Using the Api Sandbox, you could create a request like;
http://en.wikipedia.org//w/api.php?action=query&format=json&prop=revisions&titles=Cat&formatversion=2&rvprop=content&rvslots=*
Use format=json
to retrieve the Json, and rvprop=content
+ rvslots=*
to get the compete content.
Note: content is still in MediaWiki format
Result (trimmed);
{
"batchcomplete": true,
"query": {
"pages": [
{
"pageid": 6678,
"ns": 0,
"title": "Cat",
"revisions": [
{
"slots": {
"main": {
"contentmodel": "wikitext",
"contentformat": "text/x-wiki",
"content": "{{Good article}}\n{{pp-semi-indef|small=yes}}{{pp-move-indef|small=yes}}\n{{short description|Domesticated feline}}\n{{about|the species that is commonly kept as a pet|the cat family|Felidae|other uses|Cat (disambiguation)|and|Cats (disambiguation)}}\n{{technical reasons|Cat #1|the album|Cat 1 (album)}}\n{{Use dmy dates|date=February 2019}}{{Use American English|date=January 2020}}<!-- Per MOS:ENGVAR and MOS:DATEVAR, articles should conform to one overall spelling of English and date format, typically the ones with which it was created when the topic has no strong national ties. This article was created with American English, using international date format (DD Month YYYY), and should continue to be written that way. If there is a compelling reason to change it, propose a change on the talk page. -->\n{{Speciesbox\n|name= Domestic cat\n|status= DOM\n<!-- There has been extensive discussion about the choice of image in this infobox. Before replacing this image with something else, consider if it actually improves on the ENCYCLOPEDIC CRITERIA which led to this choice.... +150000 chars..
}
}
}
]
}
]
}
}
Optionally; add prop=extracts
to change output from MediaWiki format to get a 'cleaned' response;
../api.php?action=query&format=json&prop=extracts&titles=Cat&formatversion=2&rvprop=content&rvslots=*
"query": {
"pages": [
{
"pageid": 6678,
"ns": 0,
"title": "Cat",
"extract": "<p class=\"mw-empty-elt\">\n\n</p>\n\n\n\n<p class=\"mw-empty-elt\">\n\n</p>\n<p>The <b>cat</b> (<i>Felis catus</i>) is a small carnivorous mammal. It is the only domesticated species in the family Felidae and often referred to as the <b>domestic cat</b> to distinguish it from wild members of the family. The cat is either a <b>house cat</b>, a <b>farm cat</b> or a <b>feral cat</b>; latter ranges freely and avoids human contact.\nDomestic cats are valued by humans for companionship and for their ability to hunt rodents. +483000 chars
}
]
}