是否可以在单个查询中过滤维基百科文章的链接?

发布于 2024-10-06 14:02:42 字数 744 浏览 0 评论 0原文

我正在尝试利用维基百科 API 从单个调用的文章中检索嵌入了 Template:Persondata 的链接。

例如,文章“乔治克鲁尼”链接到的所有人的文章。

解决方法:

  1. 我使用 prop=links 参数获取文章列表

    http://en.wikipedia.org/w/api.php?action=query&prop=links&titles=George_Clooney&pllimit=500&plnamespace=0&format=json< /p>

  2. 然后检查每篇文章的模板是否包含Template:Persondata

    http://en.wikipedia.org/w/api.php?action=query&prop=templates&titles=*article_title*&tllimit=500&format=json

我知道通过使用list=embeddedin 查询我们可以获取特定模板的所有文章,但它用于过滤维基百科中的所有文章。

是否可以使用类似的方法来过滤我在步骤 1 中获得的文章列表?或者有更好的方法吗?

提前致谢

I am trying to make use of wikipedia API to retrieve links that has Template:Persondata embedded in it from an article in single call.

e.g. all people's articles that the article "George Clooney" links to.

as workaround:

  1. I am getting the list of articles using prop=links param

    http://en.wikipedia.org/w/api.php?action=query&prop=links&titles=George_Clooney&pllimit=500&plnamespace=0&format=json

  2. then checking the templates of each article to see if it contains Template:Persondata.

    http://en.wikipedia.org/w/api.php?action=query&prop=templates&titles=*article_title*&tllimit=500&format=json

I know that by using list=embeddedin query we can get all articles of specific Template but it is used to filter all articles in Wikipedia.

is it possible to use something similar to filter a list of articles I am getting in step 1? or is there a better way?

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

盛装女皇 2024-10-13 14:02:42

这是一个查询,它将为您提供乔治·克鲁尼页面上的链接列表以及其中嵌入的所有模板。您可以使用它来仅提取嵌入了 Template:Persondata 的文章。

http://en.wikipedia.org/w/api.php?action=query&generator=links&titles=George_Clooney&prop=templates&tllimit=500&format=json

Here is a query that will give you a list of the links on the George Clooney page, and all the templates embedded in them. You can use this to pull out only the articles ones with Template:Persondata embedded.

http://en.wikipedia.org/w/api.php?action=query&generator=links&titles=George_Clooney&prop=templates&tllimit=500&format=json

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文