如何通过维基百科 return 多个搜索结果 API?
How to return more than one search results by Wikipedia API?
我正在尝试使用 Wikipedia API 获取结果。我的查询如下。我想获取有关搜索主题的 5 个结果。就像我搜索 "India" 它应该 return 5 个关于印度的搜索结果,每个结果有 2-3 个句子。我正在尝试使用 exlimit
限制搜索结果,但它不起作用。
https://en.wikipedia.org/w/api.php?action=query&titles=india&format=jsonfm&prop=extracts&exintro=true&exlimit=5&exsentences=3
此查询 return 只有一个结果。我想要10个这样的结果。
通过使用 action=query&titles=india
您将得到 India Wikipedia page. For your case you need to use search 选项:
https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=india&gsrnamespace=0&gsrlimit=5&prop=extracts&exchars=200&exlimit=max&explaintext=1&exintro=1
其中 gsrlimit=5
是要返回的结果数,exchars=200
是要从每个结果中提取的字符数。
我正在尝试使用 Wikipedia API 获取结果。我的查询如下。我想获取有关搜索主题的 5 个结果。就像我搜索 "India" 它应该 return 5 个关于印度的搜索结果,每个结果有 2-3 个句子。我正在尝试使用 exlimit
限制搜索结果,但它不起作用。
https://en.wikipedia.org/w/api.php?action=query&titles=india&format=jsonfm&prop=extracts&exintro=true&exlimit=5&exsentences=3
此查询 return 只有一个结果。我想要10个这样的结果。
通过使用 action=query&titles=india
您将得到 India Wikipedia page. For your case you need to use search 选项:
https://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=india&gsrnamespace=0&gsrlimit=5&prop=extracts&exchars=200&exlimit=max&explaintext=1&exintro=1
其中 gsrlimit=5
是要返回的结果数,exchars=200
是要从每个结果中提取的字符数。