Skip to content

Instantly share code, notes, and snippets.

@cesare
Created January 31, 2010 13:47
Show Gist options
  • Save cesare/291073 to your computer and use it in GitHub Desktop.
Save cesare/291073 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
#
# make a summary of attendees who registered an event on ATND.org
# Usage:
# ATNDees.rb ${event_id}
#
# Output:
# creates CSV file in the current directory.
#
# see also: http://atnd.org
#
require 'csv'
require 'net/http'
require 'rubygems'
require 'nokogiri'
event_id = ARGV.shift
response_body = Net::HTTP.get(URI.parse("http://atnd.org/events/#{event_id}"))
members = []
html = Nokogiri(response_body)
html.css("ul.member_go li").each do |li|
name = li.css("a").text
message = li.xpath("text()").to_s.gsub(/^\s+:\s+/, "").gsub(/\r\n/, " ")
members << ["", name, message]
end
html.css("ul.member_over li").each do |li|
name = li.css("a").text
message = li.xpath("text()").to_s.gsub(/^\s+:\s+/, "").gsub(/\r\n/, " ")
members << ["*", name, message]
end
CSV.open("atnd-members-#{event_id}.csv", "w") do |writer|
members.each_with_index { |m,i| writer << [i] + m}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment