#!/usr/bin/ruby18 require 'rubygems' require 'mechanize' require 'hpricot' require 'cgi' cgi = CGI.new agent = WWW::Mechanize.new file = '' file = cgi.params['request'].to_s if cgi.has_key?('request') page = agent.get("http://twitter.com/" + file) body = Hpricot(page.body) (body/"head").append("") tweets = body.search("tr") tweets.each do |t| if t.search("span.entry-content").first.inner_html =~ /I don't know/i (t/"img.fn.photo").set("class", "photo fn slimed") end end # Parse the body for the phrase "I don't know" cgi.out do body.to_s end