Skip to content

Instantly share code, notes, and snippets.

@rubys
Created December 5, 2014 02:01
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 rubys/063e2ef83e77bbb01421 to your computer and use it in GitHub Desktop.
Save rubys/063e2ef83e77bbb01421 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