如何使用维基百科 API 获取完整的图像评论? [英] How to get the full image comments using the Wikipedia API?

查看:34
本文介绍了如何使用维基百科 API 获取完整的图像评论?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从 Wikipedia API 获取一些图像元数据,但注意到文本可能会被截断.

I'm grabbing some image metadata from the Wikipedia API but noticed the text could be truncated.

在此页面上:
http://en.wikipedia.org/w/api.php?action=query&prop=imageinfo&iiprop=comment&format=xml&titles=File:BrolinFoxFassbenderJonahHexJuly09.jpg

我只看到:

{{OTRS pending|year=2009|month=August|day=16}} {{Information
|Description={{en|Josh Brolin, Megan Fox, and Michael Fassbender promoting
the 2010 film ''Jonah Hex'' at San Diego Comic-Con.}} |Source=
http://www.flickr.com/photos/sdnatasha/3767292285/ |Date=

如果我查看文件的真实数据:
http://commons.wikimedia.org/wiki/Special:Export/文件:BrolinFoxFassbenderJonahHexJuly09.jpg

If i look at the real data for the file:
http://commons.wikimedia.org/wiki/Special:Export/File:BrolinFoxFassbenderJonahHexJuly09.jpg

我看到了完整的信息:

== {{int:filedesc}} =={{Information|Description={{en|Josh Brolin, Megan Fox,
and Michael Fassbender promoting the 2010 film ''Jonah Hex'' at San Diego
Comic-Con.}}|Source=
http://www.flickr.com/photos/sdnatasha/3767292285/|Date=2009-07-28|Author=NatashaBaucas
at
http://www.flickr.com/photos/sdnatasha/|Permission=Creative Commons
Attribution|other_versions=}}{{Location dec|32.705573|-117.160391|}}==
{{int:license}} =={{self|cc-by-2.0|author=Natasha
Baucas}}{{PermissionOTRS|ticket=
https://ticket.wikimedia.org/otrs/index.pl?Action=AgentTicketZoom&TicketID=3519937}}[[Category:MeganFox
in 2009]][[Category:Josh Brolin]][[Category:Michael
Fassbender]][[Category:2009 Comic-Con International]][[Category:Images
uploaded by User:Nehrams2020]

我可以使用维基百科 API 来获取未截断的评论吗?

Can I use the Wikipedia API to get the non-truncated comments?

推荐答案

您使用 iiprop=comment 获得的评论是文件历史记录"表中显示的一小段文本,以及原因它们被截断为 255 个字节,因为这就是它们最初存储在数据库中的方式.

The comments you get with iiprop=comment are the short bits of text shown in the "File history" table, and the reason they're truncated to 255 bytes is because that's how they're stored in the database to begin with.

相反,您想要的是文件描述页面的内容,您获得的方式与获得任何页面内容的方式相同:rvprop=content.

What you want, instead, is the content of the file description page, which you get the same way as you'd get any page content: rvprop=content.

(之所以会如此混乱,是因为默认的 MediaWiki 上传界面有点奇怪.图像评论确实是类似于编辑摘要的简短注释,但是当您第一次上传时新图像,您输入的相同文本同时用于页面内容和图像评论.如果评论太长而无法放入评论中—这在维基百科上很常见—评论被默默地截断,但全文仍然进入页面内容.我猜有人认为在第一次编写该界面时是有道理的;那时图像描述往往要短得多.)

(The reason why it's confusing like that is because the default MediaWiki upload interface is kind of weird. The image comments are really meant to be short notes similar to edit summaries, but when you first upload a new image, the same text you enter is used both for the page content and for the image comment. If it's too long to fit in a comment — as is common on Wikipedia these days — the comment is silently truncated, but the full text still goes into the page content. I guess someone thought that made sense back when that interface was first written; image descriptions tended to be much shorter back then.)

这篇关于如何使用维基百科 API 获取完整的图像评论?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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