Miskatonic University Press

Anonymous August Wikipedia edits from the House of Commons

r wikipedia emacs

Since August is done I was curious to see what anonymous edits had been made last month from House of Commons IPs, following on from Anonymous July Wikipedia edits from the House of Commons. It seemed from what I saw on @gccaedits that there was less going on, and indeed there was: only 18 English edits and two French. (I didn’t run through all the others.)

I did it a little differently this time, because I’d read about a simpler R library for handling JSON, jsonlite, and wanted to try it out. For fun I did it all in Org mode, which worked very well.

(I can’t highlight this snippet nicely because Org isn’t one of the languages supported by Pygments, the thing that does the fancy syntax highlighting here. So I will include screenshots!)

I have this in an Org file:

#+NAME: get-edits
#+BEGIN_SRC R :session :colnames yes
library(jsonlite)
t <- fromJSON("https://en.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuserprefix=192.197.82&ucstart=2014-08-01T00:00:00Z&ucend=2014-08-31T23:59:59Z&ucdir=newer&uclimit=500&ucprop=title|timestamp|ids|sizediff&format=json")
edits <- t$query$usercontribs
edits
#+END_SRC

It’s a very simple bit of R that runs when I hit C-c C-c:

  • use the jsonlite library
  • download [all August anonymous Wikipedia edits made from House of Commons IPs](https://en.wikipedia.org/w/api.php?action=query&list=usercontribs&ucuserprefix=192.197.82&ucstart=2014-08-01T00:00:00Z&ucend=2014-08-31T23:59:59Z&ucdir=newer&uclimit=500&ucprop=title timestamp ids sizediff&format=json), ingest it and turn it into a data frame
  • pick out the bit I’m interested in
  • show it (as a table, with column names)

It looks like this in Emacs:

Screenshot of Org mode
M-x all-praise-emacs.

I can write another bit of code, this time in Ruby, to read in data from that table and do something with it! I just hit C-c C-c on the Ruby and it generates the output below.

#+NAME: make-links
#+BEGIN_SRC ruby :var edits=get-edits :results output
edits.each do |i|
   puts %Q(<a href="https://en.wikipedia.org/w/index.php?pageid=#{i[2]}&oldid=#{i[3]}&diff=prev">#{i[6]}</a>)
end
#+END_SRC

#+RESULTS: make-links
#+begin_example
* [List of Manitoba senators](https://en.wikipedia.org/w/index.php?pageid=2134040&oldid=619454519&diff=prev)
* [Nepean Point](https://en.wikipedia.org/w/index.php?pageid=14210460&oldid=620245661&diff=prev)
* [Costas Menegakis](https://en.wikipedia.org/w/index.php?pageid=31680994&oldid=621366430&diff=prev)
* [Peter Mansbridge](https://en.wikipedia.org/w/index.php?pageid=252543&oldid=622065451&diff=prev)
* [Stephen I of Hungary](https://en.wikipedia.org/w/index.php?pageid=29594&oldid=622065708&diff=prev)
* [Peter Mansbridge](https://en.wikipedia.org/w/index.php?pageid=252543&oldid=622066606&diff=prev)
* [Union Station (Toronto)](https://en.wikipedia.org/w/index.php?pageid=455632&oldid=619445767&diff=prev)
* [Union Station (Toronto)](https://en.wikipedia.org/w/index.php?pageid=455632&oldid=619456111&diff=prev)
* [Panda Game (Ottawa vs. Carleton)](https://en.wikipedia.org/w/index.php?pageid=42957962&oldid=619967585&diff=prev)
* [Thanh Hai Ngo](https://en.wikipedia.org/w/index.php?pageid=36946133&oldid=620135598&diff=prev)
* [Glen Murray (politician)](https://en.wikipedia.org/w/index.php?pageid=643449&oldid=620415644&diff=prev)
* [Bean](https://en.wikipedia.org/w/index.php?pageid=4487&oldid=621354440&diff=prev)
* [Timeline of the Euromaidan](https://en.wikipedia.org/w/index.php?pageid=41793795&oldid=621936488&diff=prev)
* [Party Whip (Canada)](https://en.wikipedia.org/w/index.php?pageid=4050285&oldid=622222552&diff=prev)
* [Voluntary Aid Detachment](https://en.wikipedia.org/w/index.php?pageid=4940035&oldid=622907822&diff=prev)
* [David Anderson (Saskatchewan politician)](https://en.wikipedia.org/w/index.php?pageid=383866&oldid=623206768&diff=prev)
* [Dave Van Kesteren](https://en.wikipedia.org/w/index.php?pageid=3502825&oldid=619967138&diff=prev)
* [Larry Miller (Canadian politician)](https://en.wikipedia.org/w/index.php?pageid=1415770&oldid=621915107&diff=prev)
#+end_example

I wanted the output to be understood as HTML, but I couldn’t get that working. In any case, it’s no big deal, because I can move to a URL and hit C-c C-o to open it in my browser, and I can just copy it here and add explanations of each edit.

From 192.197.82.153

From 192.197.82.203

The same odd mix of good and bad we saw before.

What about French Wikipedia? Only two there, each from a different IP than above. Strange.

From 192.197.82.155 (fr)

From 192.197.82.205 (fr)

The useful edits are great, but still with the vandalism! And who knows what edits are being done in named accounts. Twenty anonymous edits this month … I’m curious to see what happens when parliament is sitting.

(Updated 2014-09-03 08:34:27 -0400 to correct the Ruby snippet.)