如何获取维基百科页面的所有链接及其Wikidata ID? [英] How to get all links and their Wikidata IDs for a Wikipedia page?

查看:721
本文介绍了如何获取维基百科页面的所有链接及其Wikidata ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(何时)可以进行以下操作?

(When) will the following be possible?

  • 在单个查询/API调用中获取Wikipedia页面上所有链接的列表以及它们各自的Wikidata ID.

  • get the list of all links on a Wikipedia page with their respective Wikidata IDs in a single query/API call.

通过查询接收各个Wikidata项的附加信息,例如属性值.

receive additional information of the respective Wikidata items like a property value with the query.

推荐答案

要获取所有Wikipedia页面链接,您必须使用 Wikipedia API ,并且要获取所有Wikidata项目属性,您需要 Wikidata API ,因此无法创建对两个API有两个请求的一个查询.但!您的问题的第一部分已经是可能的.关于第二个……您什么也没有说,您需要从Wikidata获得什么信息.

To get all Wikipedia page links you have to use Wikipedia API, and to get all Wikidata item properties you need Wikidata API, so it is not possible to create one query with two requests to both APIs. But! The first part of your question is already possible. And about the second... you didn't say anything for this what information you need from Wikidata.

您可以获取所有Wikipedia页面链接的Wikidata ID和许多其他信息,例如坐标,引用,内部和外部链接,图像,文本内容,参与者,历史记录,页面权限,类别,模板等.为此,我们只能使用Wikipedia API,因为我们的入口点是Wikipedia页面以及该API的 generator 功能.

You can get Wikidata IDs and a lot of other information for all Wikipedia page links, like coordinates, refs, internal and external links, images, text content, contributors, history, page rights, categories, templates etc... To do this we can use only Wikipedia API because our entry point is the Wikipedia page, plus generator feature of the API.

例如,这是如何获取

For example, this is how to get Wikidata ID, short intro text and the main image for first 20 interwiki links on Dolphin Wikipedia page:

https://en.wikipedia.org/w/api.php?action=query&generator=links&format=xml&redirects=1&titles=Dolphin&prop=pageprops|extracts|pageimages&gpllimit=20&ppprop=wikibase_item&exintro=1&exlimit=20&piprop=name&pilimit=20

主要查询参数:

Main query parameters:

  • action=query&format=xml&redirects=1&titles=Dolphin
  • generator=links-获取所有页面链接(与gpllimit=20一起使用)
  • prop=pageprops|extracts|pageimages-从链接中获得什么
  • action=query&format=xml&redirects=1&titles=Dolphin
  • generator=links - to get all page links (works together with gpllimit=20)
  • prop=pageprops|extracts|pageimages - what to get from the links

属性:

  • pageprops -获取Wikidata ID (与ppprop=wikibase_item一起使用)
  • 提取-获取第一个文本该页面上的行(适用于exintro=1exlimit=20)
  • pageimages -获取主图像(适用于piprop=namepilimit=20)
  • pageprops - to get Wikidata ID (works with ppprop=wikibase_item)
  • extracts - to get first text lines from that page (works with exintro=1 and exlimit=20)
  • pageimages - to get main image (works with piprop=name and pilimit=20)

您可以通过相同的方式并在此处列出其他信息在参数prop中.

In the same way you can get and another information listed here in parameter prop.

这篇关于如何获取维基百科页面的所有链接及其Wikidata ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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