Wikidata API wbsearchentities:为什么 Python 中的结果与 Wikidata 中的结果不同? [英] Wikidata API wbsearchentities: why are results not the same in Python than in Wikidata?

查看:30
本文介绍了Wikidata API wbsearchentities:为什么 Python 中的结果与 Wikidata 中的结果不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 python 请求中使用 wbsearchentities (wikidata api),我想知道为什么返回的结果与在 Wikidata 上看到的结果不同.例如,Python 中的以下命令:

I'm using wbsearchentities (wikidata api) in a python request and I'm wondering why returned results are not the same that those seen on Wikidata. For example, the following command in Python:

url = "https://www.wikidata.org/w/api.php?action=wbsearchentities&search=%s&format=json&limit=50&formatversion=2&language=en" % ('New York Landmarks Preservation Commission')
r = requests.post(url,headers={"User-Agent" : "Magic Browser"})

在维基数据的搜索框中只返回相同的搜索返回2个结果(一个是好的:纽约城市地标保护委员会.

returns nothing but the same search in the search box of Wikidata returns 2 results (one is the good one: New York City Landmarks Preservation Commission.

理想情况下,我希望从我的 python 请求中返回所有这些结果.

Ideally, I would like to have all these results returned from my python request.

推荐答案

维基数据右上角的搜索框使用 wbsearchentities API 模块提供自动建议下拉搜索.

The search box in the top right of Wikidata uses the wbsearchentities API module to provide the auto suggestion dropdown search.

如果您在输入搜索后按 Enter 而不是单击其中一项建议,您最终将进入 Special:Search 页面.

If you press enter after entering your search instead of clicking on one of the suggestions you will end up on the Special:Search page.

如您所见,它们的 API 结果返回 没有结果但是特殊页面.

As you can see they API result returns no results but the special page does.

这是由于这些搜索以完全不同的方式工作.

That is due to these searches working in entirely different ways.

  • Special:Search 页面是 Wikibase 提供的 MediaWiki 概念数据到.
  • 维基库自身提供的 wbsearchentities API 模块.

这篇关于Wikidata API wbsearchentities:为什么 Python 中的结果与 Wikidata 中的结果不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆