我有以下维基百科 API 搜索查询:
http://en.wikipedia.org/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
我只想列出名人 - 有没有办法做到这一点?
最佳答案
没有一种确切的方法可以将您的搜索结果仅限于名人。但是,您可以使用几个不同的 filters in with Wikipedia's CirrusSearch粗略地将您的结果缩小到人们:
incategory:
你能找到一个包含你想要的人的类别吗?类别可能不是一个很好的解决方案,因为它们可能不方便具体。 linksto:
关于人的文章是否链接到共同的文章? hastemplate:
你能找到一个用于名人传记的模板吗?模板 {{birth date}}
可能是一个很好的解决方案(如果可以将您的搜索限制在大多数具有无争议的已知出生日期的非虚构人物)。 例如,查看与
hastemplate:Birth_date
相同的搜索结果看人:https://en.wikipedia.org/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": "https://upload.wikimedia.org/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": "https://upload.wikimedia.org/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 \u2013 18 April 1955) was a German-born theoretical physicist.</p>"
},
"1139788": {
"pageid": 1139788,
"ns": 0,
"title": "Alfred Einstein",
"index": 6,
"thumbnail": {
"source": "https://upload.wikimedia.org/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 \u2013 February 13, 1952) was a German-American musicologist and music editor.</p>"
},
...
有一天,你应该能够使用维基数据在维基百科上搜索 instance of human 的实体。 .现在,我们必须使用搜索过滤器。
关于api - 维基百科 API : search for famous people,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30418378/