Skip to content

Instantly share code, notes, and snippets.

@mnot mnot/cgmailstats.rb forked from rubys/cgmailstats.rb
Last active Aug 29, 2015

Embed
What would you like to do?
require 'nokogumbo'
require 'date'
require 'json'
start = Date.today - 105
results = {}
index = 'http://www.w3.org/community/groups/'
groups = Nokogiri::HTML5.get(index)
groups = groups.search('a.h3').map {|a| a['href'].sub(/^#/, '')}
groups.each do |group|
list = "http://lists.w3.org/Archives/Public/public-#{group}"
doc = Nokogiri::HTML5.get(list)
count = 0
doc.search('tbody tr').each do |tr|
next if tr.at('td').text == 'n/a'
date=Date.parse(tr.at('td').text)
count += tr.search('td').last.text.to_i if date > start
end
results[group] = count
end
puts JSON.pretty_generate(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.