Wikipedia api fulltext search to return articles with title, snippet and image

前端 未结 2 1167
礼貌的吻别
礼貌的吻别 2021-01-31 12:27

I\'ve been looking for a way to query the wikipedia api based on a search string for a list of articles with the following properties:

  • Title
  • Snippet/Descr
2条回答
  •  醉梦人生
    2021-01-31 12:35

    As Bergi suggested, using generators is the way to go here. Specifically what I would do:

    • use list=search as a generator, to get the list of articles
    • use prop=pageimages to get a representative image for each article
    • use prop=extracts to get a description for each article

    The whole query could look like this:

    http://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrsearch=test&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max

提交回复
热议问题