如何获取维基百科上文章的完整更改历史记录?

发布于 2024-09-11 17:10:02 字数 419 浏览 0 评论 0原文

我想要一种方法来下载维基百科上热门文章的历史记录中的每个页面的内容。换句话说,我想获得一篇文章的每次编辑的完整内容。我该怎么做呢?

有没有一种简单的方法可以使用 Wikipedia API 来做到这一点?我看了看,没有发现任何简单的解决方案。我还研究了 PyWikipedia Bot 页面上的脚本 (http://botwiki.sno.cc/w/index.php?title=Template:Script&oldid=3813)并没有找到任何有用的东西。在 Python 或 Java 中执行此操作的一些简单方法将是最好的,但我愿意接受任何可以获取数据的简单解决方案。

I'd like a way to download the content of every page in the history of a popular article on Wikipedia. In other words I want to get the full contents of every edit for a single article. How would I go about doing this?

Is there a simple way to do this using the Wikipedia API. I looked and didn't find anything the popped out as a simple solution. I've also looked into the scripts on the PyWikipedia Bot page (http://botwiki.sno.cc/w/index.php?title=Template:Script&oldid=3813) and didn't find anything that was useful. Some simple way to do it in Python or Java would be the best, but I'm open to any simple solution that will get me the data.

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

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

发布评论

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

评论(2

呢古 2024-09-18 17:10:02

为此有多种选择。您可以使用 Special:Export 特殊页面来获取页面历史记录的 XML 流。或者,您也可以使用 /w/api.php 下的 API。使用 action=query&title=$TITLE&prop=revisions&rvprop=timestamp|user|content 等来获取历史记录。
Pywikipedia 提供了一个接口,但我不知道如何调用它。 Python 的替代库 mwclient 也通过 site.pages[page_title] 提供此功能。修订()

There are multiple options for this. You can use the Special:Export special page to fetch an XML stream of the page history. Or you can use the API, found under /w/api.php. Use action=query&title=$TITLE&prop=revisions&rvprop=timestamp|user|content etc. to fetch the history.
Pywikipedia provides an interface to this, but I do not know by heart how to call it. An alternative library for Python, mwclient, also provides this, via site.pages[page_title].revisions()

凉世弥音 2024-09-18 17:10:02

一种解决方案是解析 Wikipedia XML 转储。

只是想我会把它放在那里。

如果您只获得一页,那就太过分了。但是,如果您不需要非常最新的信息,那么使用 XML 的优点是可以一次性下载,而不需要重复的网络点击。

Well, one solution is to parse the Wikipedia XML dump.

Just thought I'd put that out there.

If you're only getting one page, that's overkill. But if you don't need the very very latest information, using the XML would have the advantage of being a one-time download instead of repeated network hits.

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