MediaWiki API to fetch all links from the See Also section of an article

247 views Asked by At

https://www.mediawiki.org/wiki/API:Query

From above link please suggest me an appropriate API to fetch/get all the links of See Also section of an article.

For Example:

This is the See Also section if we search Pune

I want a list of the above 5 links.

There is an API to get the external links associated with an article: https://en.wikipedia.org/w/api.php?format=json&action=query&titles=Pune&prop=extlinks

Now, coming back to the original question about See Also links - If there is no proper API then how can we extract the same links if we have the wikitext contentmodel.

Example of wikitext: https://en.wikipedia.org/w/api.php?format=json&action=query&titles=Pune&prop=revisions&rvprop=content

1

There are 1 answers

0
smartse On

As far as I know, there's no way to do this in a single call, but you can use https://en.wikipedia.org/w/api.php?action=parse&page=Pune&format=json&prop=sections to give all of the sections in an article then iterate through the results to find the index of the section where 'line' == 'See also' e.g. in this case 42 and then use https://en.wikipedia.org/w/api.php?action=parse&page=Pune&format=json&section=42 to give you just that section.