维基百科API:搜索名人

编程入门 行业动态 更新时间:2024-10-17 00:24:33
本文介绍了维基百科API:搜索名人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有以下维基百科 API 搜索查询:

en.wikipedia/w/api.php?&action=query&generator=search&gsrnamespace=0&gsrlimit=20&prop=pageimages|extracts&pilimit=max&exintro&exsentences=1&exlimit=max&continue&pithumbsize=100&gsrlimit=20&prop=pageimages|extracts&pilimit=max&exintro&exsentences=1&exlimit=max&continue&pithumbsize=100&gsrlimitEinstein/p>

我只想列出名人 - 有没有办法做到这一点?

解决方案

没有一种确切的方法可以将您的搜索结果仅限于名人.但是,您可以使用一些不同的 过滤器维基百科的 CirrusSearch 将您的搜索结果粗略地缩小到人们的范围:

  • incategory: 你能找到一个包含你想要的人的类别吗?类别可能不是一个好的解决方案,因为它们可能不方便具体.
  • linksto:关于人物的文章是否链接到普通文章?
  • hastemplate: 你能找到一个用于名人传记的模板吗?模板 {{birth date}} 可能是一个不错的选择解决方案(如果可以将您的搜索范围限制为大多数具有无争议的已知出生日期的非虚构人物).

例如,使用 hastemplate:Birth_date 查看相同的搜索结果以查看人员:

en.wikipedia/w/api.php?&action=query&generator=search&gsrnamespace=0&gsrlimit=20&prop=pageimages|extracts&pilimit=max&exintro&exsentences=1&exlimit=max&continue&pithumbsize=100&d阿尔伯特%20爱因斯坦

{批量完成":",继续": {gsroffset":20,继续":gsroffset||"},询问": {页面":{92733":{pageid":92733,ns":0,"title": "阿尔伯特·A·迈克尔逊",索引":14,缩略图":{"source": "upload.wikimedia/wikipedia/commons/thumb/9/9e/Albert_Abraham_Michelson2.jpg/71px-Albert_Abraham_Michelson2.jpg",宽度":71,高度":100},"pageimage": "Albert_Abraham_Michelson2.jpg","extract": "<p><b>Albert Abraham Michelson</b>(姓氏发音英语化为 \"Michael-son\", December 19, 1852 \u2013 May 9, 1931)是一位美国物理学家他在测量光速方面的工作,尤其是迈克尔逊\u2013莫雷实验.</p>"},736":{pageid":736,ns":0,"title": "阿尔伯特·爱因斯坦",指数":1,缩略图":{"来源": "upload.wikimedia/wikipedia/commons/thumb/3/3e/Einstein_1921_by_F_Schmutzer_-_restoration.jpg/76px-Einstein_1921_by_F_Schmutzer_-_restoration.jpg",宽度":76,高度":100},"pageimage": "Einstein_1921_by_F_Schmutzer__-_restoration.jpg","extract": "<p><b>阿尔伯特·爱因斯坦</b> (<span><span>/<span><span title=\"/\u02c8/主要应力跟随\">;\u02c8</span><span title=\"/a\u026a/long 'i' in 'tide'\">a\u026a</span><span title=\"'n' in 'no'\">n</span><span title=\"'s' in 'sigh'\">s</span><span title=\"'t' in 'tie'\">t</span><span title=\"/a\u026a/long 'i' in 'tide'\">a\u026a</span><span title=\"'n' in 'no'\">n</span></span>/</span></span>; <small>德语:</small> <span title=\"在国际上的代表拼音字母 (IPA)\">[\u02c8alb\u025b\u0250\u032ft \u02c8a\u026an\u0283ta\u026an]</span>;1879 年 3 月 14 日&#160;\u0250\u032ft \u02c8a\u026an\u0283ta\u026an]</span>;1879 年 3 月 14 日&#160;\5185 4 月天生的理论物理学家.</p>"},1139788":{pageid":1139788,ns":0,"title": "阿尔弗雷德·爱因斯坦",指数":6,缩略图":{"source": "upload.wikimedia/wikipedia/en/thumb/1/12/Alfred_Einstein.jpg/70px-Alfred_Einstein.jpg",宽度":70,高度":100},"pageimage": "Alfred_Einstein.jpg","extract": "<p><b>阿尔弗雷德·爱因斯坦</b>(1880 年 12 月 30 日&#160;\u2013 年 2 月 13 日,1952 年 2 月 13 日)是德裔美国音乐学家和音乐编辑.</p>"},...

总有一天,您应该能够使用维基数据在维基百科上搜索属于人类实例的实体.现在,我们必须使用搜索过滤器.

I have the following Wikipedia API search query:

en.wikipedia/w/api.php?&action=query&generator=search&gsrnamespace=0&gsrlimit=20&prop=pageimages|extracts&pilimit=max&exintro&exsentences=1&exlimit=max&continue&pithumbsize=100&gsrsearch=Albert%20Einstein

I just want to list famous people - is there a way to do that?

解决方案

There isn't an exact way to limit your search results to only famous people. However, you can use a few different filters in with Wikipedia's CirrusSearch to roughly narrow your results to people:

  • incategory: Can you find a category that includes the people you want? Categories may not be a great solution, since they may be inconveniently specific.
  • linksto: Do articles about people link to a common article?
  • hastemplate: Can you find a template that is used on biographies of famous people? The template {{birth date}} may be a good solution (if it's fine to limit your search to mostly non-fictional people with non-disputed known birthdates).

For example, see your same search result with hastemplate:Birth_date to see people:

en.wikipedia/w/api.php?&action=query&generator=search&gsrnamespace=0&gsrlimit=20&prop=pageimages|extracts&pilimit=max&exintro&exsentences=1&exlimit=max&continue&pithumbsize=100&gsrsearch=hastemplate%3ABirth_date+Albert%20Einstein

{ "batchcomplete": "", "continue": { "gsroffset": 20, "continue": "gsroffset||" }, "query": { "pages": { "92733": { "pageid": 92733, "ns": 0, "title": "Albert A. Michelson", "index": 14, "thumbnail": { "source": "upload.wikimedia/wikipedia/commons/thumb/9/9e/Albert_Abraham_Michelson2.jpg/71px-Albert_Abraham_Michelson2.jpg", "width": 71, "height": 100 }, "pageimage": "Albert_Abraham_Michelson2.jpg", "extract": "<p><b>Albert Abraham Michelson</b> (surname pronunciation anglicized as \"Michael-son\", December 19, 1852 \u2013 May 9, 1931) was an American physicist known for his work on the measurement of the speed of light and especially for the Michelson\u2013Morley experiment.</p>" }, "736": { "pageid": 736, "ns": 0, "title": "Albert Einstein", "index": 1, "thumbnail": { "source": "upload.wikimedia/wikipedia/commons/thumb/3/3e/Einstein_1921_by_F_Schmutzer_-_restoration.jpg/76px-Einstein_1921_by_F_Schmutzer_-_restoration.jpg", "width": 76, "height": 100 }, "pageimage": "Einstein_1921_by_F_Schmutzer_-_restoration.jpg", "extract": "<p><b>Albert Einstein</b> (<span><span>/<span><span title=\"/\u02c8/ primary stress follows\">\u02c8</span><span title=\"/a\u026a/ long 'i' in 'tide'\">a\u026a</span><span title=\"'n' in 'no'\">n</span><span title=\"'s' in 'sigh'\">s</span><span title=\"'t' in 'tie'\">t</span><span title=\"/a\u026a/ long 'i' in 'tide'\">a\u026a</span><span title=\"'n' in 'no'\">n</span></span>/</span></span>; <small>German:</small> <span title=\"Representation in the International Phonetic Alphabet (IPA)\">[\u02c8alb\u025b\u0250\u032ft \u02c8a\u026an\u0283ta\u026an]</span>; 14 March 1879&#160;\u2013 18 April 1955) was a German-born theoretical physicist.</p>" }, "1139788": { "pageid": 1139788, "ns": 0, "title": "Alfred Einstein", "index": 6, "thumbnail": { "source": "upload.wikimedia/wikipedia/en/thumb/1/12/Alfred_Einstein.jpg/70px-Alfred_Einstein.jpg", "width": 70, "height": 100 }, "pageimage": "Alfred_Einstein.jpg", "extract": "<p><b>Alfred Einstein</b> (December 30, 1880&#160;\u2013 February 13, 1952) was a German-American musicologist and music editor.</p>" }, ...

Someday, you should be able to use Wikidata to search for entities on Wikipedia that are an instance of human. For now, we'll have to work with search filters.

更多推荐

维基百科API:搜索名人

本文发布于:2023-06-07 17:37:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/589411.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:维基百科   名人   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!