Created
January 31, 2010 13:47
-
-
Save cesare/291073 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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