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

查看:129
本文介绍了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"})

返回任何内容,但在Wikidata的搜索框中进行相同的搜索将返回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.

推荐答案

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

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

如果您在输入搜索内容后按Enter键,而不是点击其中一项建议,则最终会出现在

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概念 数据发送到.
  • Wikibase本身提供的wbsearchentities API模块.
  • The Special:Search page is a MediaWiki concept that Wikibase provides data to.
  • The wbsearchentities API module provided by Wikibase itself.

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

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