Fetch excerpt from Wikipedia article?

后端 未结 4 1380
刺人心
刺人心 2020-12-08 17:37

I\'ve been up and down the Wikipedia API, but I can\'t figure out if there\'s a nice way to fetch the excerpt of an article (usually the first paragraph). It would

4条回答
  •  -上瘾入骨i
    2020-12-08 17:40

    As ARAVIND VR notes, on wikis running the MobileFrontend extension — which includes Wikipedia — you can easily get an excerpt of an article via the MediaWiki API by using the prop=extracts API query.

    For example, this link will give you a short excerpt of the Stack Overflow article on Wikipedia in a JSON wrapper.

    The various options to the query can be used to control the excerpt format (HTML or plain text), its maximum length (in characters and/or sentences, and optionally restricting it to the intro section of the article) and the formatting of section headings in the output. It's also possible to obtain intro extracts from more than one article in a single query.

提交回复
热议问题