Skip to content

Instantly share code, notes, and snippets.

@zolrath
Created February 25, 2012 21:07
Show Gist options
  • Save zolrath/1910726 to your computer and use it in GitHub Desktop.
Save zolrath/1910726 to your computer and use it in GitHub Desktop.
require 'nokogiri'
PERSON = "Andrew Marrone"
def extract_messages_of(name)
messages = []
face = Nokogiri::XML(File.open("messages.html"))
face.css("div.msgbody").each do |n|
if n.parent.css('span').text == name
messages << n.text.strip + "."
end
end
messages
end
messages = extract_messages_of(PERSON)
File.open("#{PERSON.gsub(" ", "_")}_messages.txt", 'w') {|f| f.write(messages.join(' ')) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment