Wikidata API wbsearchentities: why are results not the same in Python than in Wikidata?

亡梦爱人 提交于 2019-11-28 05:07:52

问题


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"})

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.

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


回答1:


The search box in the top right of Wikidata uses the wbsearchentities API module to provide the auto suggestion dropdown 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.

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.

  • The Special:Search page is a MediaWiki concept that Wikibase provides data to.
  • The wbsearchentities API module provided by Wikibase itself.


来源:https://stackoverflow.com/questions/37170179/wikidata-api-wbsearchentities-why-are-results-not-the-same-in-python-than-in-wi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!