Skip to content

Instantly share code, notes, and snippets.

@michenriksen
Created December 15, 2017 21:17
Show Gist options
  • Save michenriksen/4a2ce762d673a1fc0b88e33b94a6db91 to your computer and use it in GitHub Desktop.
Save michenriksen/4a2ce762d673a1fc0b88e33b94a6db91 to your computer and use it in GitHub Desktop.
FCC Wiki edits stats
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
TOP 10 CONTRIBUTORS:
192.104.54.21: 50 (https://en.m.wikipedia.org/wiki/Special:Contributions/192.104.54.21)
192.104.54.79: 49 (https://en.m.wikipedia.org/wiki/Special:Contributions/192.104.54.79)
192.104.54.179: 31 (https://en.m.wikipedia.org/wiki/Special:Contributions/192.104.54.179)
192.104.54.77: 23 (https://en.m.wikipedia.org/wiki/Special:Contributions/192.104.54.77)
192.104.54.166: 11 (https://en.m.wikipedia.org/wiki/Special:Contributions/192.104.54.166)
192.104.54.4: 9 (https://en.m.wikipedia.org/wiki/Special:Contributions/192.104.54.4)
192.104.54.1: 1 (https://en.m.wikipedia.org/wiki/Special:Contributions/192.104.54.1)
192.133.125.248: 0 (https://en.m.wikipedia.org/wiki/Special:Contributions/192.133.125.248)
192.133.125.247: 0 (https://en.m.wikipedia.org/wiki/Special:Contributions/192.133.125.247)
192.133.125.246: 0 (https://en.m.wikipedia.org/wiki/Special:Contributions/192.133.125.246)
require "httparty"
require "ipaddr"
ranges = %w(192.104.54.0/24 192.133.125.0/24)
edits = {}
ranges.each do |range|
ips = IPAddr.new(range).to_range.to_a.map(&:to_s)
ips.each do |ip|
url = "https://en.m.wikipedia.org/wiki/Special:Contributions/#{ip}"
response = HTTParty.get(url)
next unless response.code == 200
edits[ip] = response.body.scan(/page-summary/).count
print "."
end
end
puts "\n\nTOP 10 CONTRIBUTORS:\n\n"
edits.sort_by { |_key, value| value }.reverse.to_h.take(10).each do |edit|
ip, edits = edit
puts "#{ip}: #{edits} (https://en.m.wikipedia.org/wiki/Special:Contributions/#{ip})"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment