Created
September 24, 2012 08:56
-
-
Save fnielsen/3775006 to your computer and use it in GitHub Desktop.
Statistics on blocked IPs in a MediaWiki
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pylab import * | |
from urllib2 import urlopen | |
from simplejson import load | |
from re import findall | |
url = 'http://neuro.imm.dtu.dk/w/api.php?' + \ | |
'action=query&list=blocks&' + \ | |
'bkprop=id|user|by|timestamp|expiry|reason|range|flags&' + \ | |
'bklimit=500&format=json' | |
data = load(urlopen(url)) | |
users = [ block['user'] for block in data['query']['blocks'] if 'user' | |
in block ] | |
ip_users = filter(lambda s: findall(r'^\d+', s), users) | |
ip = map(lambda s : int(findall(r'\d+', s)[0]), ip_users) | |
dummy = hist(ip, arange(256), orientation='horizontal') | |
xlabel('Number of blocks'); ylabel('First byte of IP'); | |
show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment