Search code examples
mediawikimediawiki-api

get internal links from Introduction in article


For a given article on Wikipedia, I would like to use the Mediawiki API to extract the internal links from the introduction section of an article.

Eximilar to the prop=extracts&exintro= setting but with the contents of the links.


Solution

  • Get the lead wikitext with either extracts or revisions for section 0 (the first has sanity checks against a very long intro / an article with no section headings at all, but might be cut off at an awkward position), pass it to parse and set prop=links.