API for getting edits on Wikipedia

两盒软妹~` 提交于 2019-12-24 09:48:42

问题


I want to get the text of the edit made on a Wikipedia page before and after the edit. I have this url:

https://en.wikipedia.org/w/index.php?diff=328391582&oldid=328391343

But, I want the text in the json format so that I can directly use it in my program. Is there any API provided by MediaWiki that gives me the old and new text after an edit or do I have to parse the HTML page using a parser?


回答1:


Try this: https://www.mediawiki.org/wiki/API:Revisions

There are a few options which may be of use, such as:

  1. rvparse: Parse revision content. For performance reasons if this option is used, rvlimit is enforced to 1.

  2. rvdifftotext: Text to diff each revision to.

If those fail there's still

  1. rvprop / ids: Get the revid and, from 1.16 onward, the parentid

Then once you get the parent ID, you can compare the text of the two.



来源:https://stackoverflow.com/questions/40313820/api-for-getting-edits-on-wikipedia

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!