How to get a list of all films on Wikidata?

百般思念 提交于 2019-12-06 08:09:56

问题


I was using Freebase to get all movies/films there for my website, but it's getting shut down soon. so I was searching for another free database for movies and came across Wikidata. To be honest it's too complicated to understand how to query all the movies.

So I thought you guys could help me to get all the movies in Wikidata. In the future I want to include TV shows and series as well.

Programming language doesn't matter, I want to use web query with a link.


回答1:


you can look for all the entities that are an instance of film, which in Wikidata is translated as:

P31 (instance of) -> Q11424 (film)

For the moment, the best way to do this query is to use the wdq.wmflabs.org API, where this query translate as: http://wdq.wmflabs.org/api?q=claim[31:11424] (avoid making this query in a browser as it will probably make it crash due to the ). At the moment I'm writting, this requests returns 157038 items in the form of numeric ids (ex: 125). To get the Wikidata ids, just add a leading Q -> Q125.

To get the labels and data from all those Wikidata ids, use the Wikidata API wbgetentities action: https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q180736&format=json&languages=en. Beware of the 50 entities per-query limit though

[UPDATE] Wikidata now offers a SPARQL endpoints: the same query in SPARQL or even this same query but also including subclasses of films



来源:https://stackoverflow.com/questions/32166730/how-to-get-a-list-of-all-films-on-wikidata

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