Skip to content

Instantly share code, notes, and snippets.

@mnot
Forked from rubys/cgmailstats.rb
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnot/67822f04d9809a04f7d2 to your computer and use it in GitHub Desktop.
Save mnot/67822f04d9809a04f7d2 to your computer and use it in GitHub Desktop.
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