Created
March 8, 2009 16:30
-
-
Save jubishop/75824 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
require 'rubygems' | |
require 'hpricot' | |
require 'open-uri' | |
doc = Hpricot(open("http://shirt.woot.com/Derby/Default.aspx")) | |
as = doc/"a" | |
File.open("newoot.html", "w+") { |file| | |
file.puts '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | |
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8" /> | |
<title>Woot Derty</title> | |
</head> | |
<body> | |
' | |
as.each { |a| | |
img = (a/"img").first | |
if (img and img.attributes['title'] and img.attributes['lazysrc']) | |
file.puts '<div style="float:left">' | |
file.puts '<p>'+img.attributes['title']+'</p>' | |
file.puts '<a href="http://shirt.woot.com'+a.attributes['href']+'"><img src="'+img.attributes['lazysrc']+'"/></a>' | |
file.puts '</div>' | |
end | |
} | |
file.puts ' | |
</body> | |
</html>' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment