如何按给定日期检索维基百科文章的历史版本?

How to retrieve history version of Wikipedia article by given date?

有没有办法使用 MediaWiki API 或任何其他工具自动检索使用大概日期的维基百科文章的先前版本(不知道 'oldid' 值)?

例如,如何使用 "December 2016"“2016 年 12 月 20 日”检索 2016 年 12 月 20 日的 history version of Stack Overflow 文章 或这一天前后的日期作为参数?

您可以使用 2016 年 12 月 20 日 00:00:00 之后制作的 MediaWiki API with action query and property revisions. To get the first revision of the Stack Overflow 来执行此操作 您可以使用此:

https://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Stack%20Overflow&rvlimit=1&rvprop=content&rvdir=newer&rvstart=2016-12-20T00:00:00Z

其中 rvlimit 是要返回的历史版本数,rvdir=newer 表示结果(如果 rvlimit > 1)到按从旧到新的顺序列出,rvstart 是获取页面历史版本的时间。

Special:Export 页面上的 curl 请求也可能有所帮助,方法是将偏移参数设置为类似“2016-12-20T00:00:00Z”的内容

curl -d "" 'https://en.wikipedia.org/w/index.php?title=Special:Export&pages=Stack_Overflow&offset=2016-12-20T00:00:00Z&limit=1&action=submit'