This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

niwa_stats.py

By: a guest on Mar 30th, 2012  |  syntax: None  |  size: 1.92 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. from urllib import urlopen
  2. from json import loads
  3. apis = ["http://www.pikminwiki.com/api.php","http://bulbapedia.bulbagarden.net/w/api.php","http://www.donkeykongwiki.com/api.php","http://www.fireemblemwiki.org/api.php","http://mutecity.org/w/api.php","http://goldensunwiki.net/api.php","http://www.kidicaruswiki.org/api.php","http://www.starfoxwiki.org/w/api.php","http://www.metroidwiki.org/w/api.php","http://www.niwanetwork.org/wiki/api.php","http://nookipedia.com/w/api.php","http://www.pikminfanon.com/api.php","http://www.ssbwiki.com/api.php","http://www.starfywiki.org/api.php","http://strategywiki.org/w/api.php","http://www.mariowiki.com/api.php","http://www.wikibound.info/api.php","http://wikirby.com/api.php","http://www.zeldawiki.org/api.php","http://dragon-quest.org/w/api.php"]
  4. labels = ["Pikipedia","Bulbapedia","Donkey Kong Wiki","Fire Emblem Wiki","F-Zero Wiki","Golden Sun Universe","Icaruspedia","Lylat Wiki","Metroid Wiki","Nintendo Wiki","Nookipedia","Pikmin Fanon Wiki","Smash Wiki","Starfy Wiki","Strategy Wiki","Mario Wiki","Wikibound","Wikirby","Zelda Wiki","Dragon Quest Wiki"]
  5. cats = ['articles','edits','images','users','activeusers','admins']
  6. totals = [0,0,0,0,0,0]
  7. f = open("niwa_stats.html","w")
  8. f.write('<html><head><title>NIWA Statistics</title></head><body><table border="1"><tr><td colspan="7">NIWA Statistics</td></tr><tr><td>Wiki Name</td><td>Articles</td><td>Edits</td><td>Media</td><td>Users</td><td>Active Users</td><td>Admins</td></tr>')
  9. for idx, val in enumerate(apis):
  10.   f.write('<tr><td>' + labels[idx] + '</td>')
  11.   for idy, cat in enumerate(cats):
  12.     x = loads(urlopen(val + '?format=json&action=query&meta=siteinfo&siprop=statistics').read().decode())['query']['statistics'][cat]
  13.     f.write('<td>' + str(x) + '</td>')
  14.     totals[idy] += x
  15.   f.write('</tr>')
  16. f.write('<tr><td>Totals</td>')
  17. for t in totals:
  18.   f.write('<td>' + str(t) + '</td>')
  19. f.write('</tr></table></body></html>')
  20. f.close()
clone this paste RAW Paste Data