Learn R Programming

WikipediR (version 1.0.0)

wiki_diff: Generates a "diff" between a pair of revisions

Description

wiki_diff generates a diff between two revisions in a MediaWiki page. This is provided as an XML-parsable blob inside the returned JSON object.

Usage

wiki_diff(con, revisions, properties = c("ids", "flags", "timestamp",
                                       "user", "userid", "size",
                                       "sha1", "contentmodel", "comment",
                                       "parsedcomment", "tags", "flagged"),
            direction = c("prev", "next", "cur"))

Arguments

con
A connector object, generated by wiki_con, that corresponds to the project you're trying to query.
revisions
The revision IDs of each "start" revision.
properties
Properties you're trying to retrieve about that revision, should you want to; options include "ids" (the revision ID of the revision...which is pointless), "flags" (whether the revision was 'minor' or not), "timestamp" (the timestamp of the revision, whic
direction
The direction you want the diff to go in from the revisionID you have provided. Options are "prev" (compare to the previous revision on that page), "next" (compare to the next revision on that page) and "cur" (compare to the current, extant version of the

Warnings

MediaWiki's API is deliberately designed to restrict users' ability to make computing-intense requests - such as diff computation. As a result, the API only allows requests for one uncached diff in each request. If you ask for multiple diffs, some uncached and some cached, you will be provided with the cached diffs, one of the uncached diffs, and a warning.

If you're going to be asking for a lot of diffs, some of which may not be cached, it may be more sensible to retrieve the revisions themselves using wiki_revision and compute the diffs yourself.

See Also

wiki_con

Examples

Run this code
#Create connector
  ih_connector <- wiki_con(language = "en", project = "wikipedia")
  
  #Ask for a diff between revision 602943163 and the next-dated revision on that page,
  #also retrieving the username of the person who /made/ said revision
  ih_pagdiff <- wiki_diff(con = ih_connector, revision = 602943163,
                          properties = "user", direction = "next")

Run the code above in your browser using DataLab