Created
April 23, 2009 23:53
-
-
Save JosephPecoraro/100848 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
require 'rubygems' | |
require 'hpricot' # hpricot-0.6.164 | |
html = <<END | |
<html><head></head><body><table> | |
<tr><td>R0C0</td><td>R0C1</td><td>R0C2</td><td>R0C3</td></tr> | |
<tr><td>R1C0</td><td>R1C1</td><td>R1C2</td><td>R1C3</td></tr> | |
<tr><td>R2C0</td><td>R2C1</td><td>R2C2</td><td>R2C3</td></tr> | |
</table></body></html> | |
END | |
puts html | |
doc = Hpricot(html) | |
yours = (doc/"html/body/table/tr").map {|row| (row/"td").map {|ele| ele.inner_text}} | |
mine = (doc/"html/body/table/tr").map do |row| | |
(row/"td").map do |cell| | |
cell.inner_text | |
end | |
end | |
p yours | |
p mine | |
p yours == mine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment