Skip to content

Instantly share code, notes, and snippets.

@darrinholst
Created January 13, 2010 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrinholst/276478 to your computer and use it in GitHub Desktop.
Save darrinholst/276478 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'nokogiri'
html = <<EOS
<html>
<head>
<title>test</title>
</head>
<body>
<table id="some_id">
<thead>
<tr><th>header</th></tr>
</thead>
<tbody>
<tr><td>row 1</td></tr>
<tr><td>row 2</td></tr>
<tr><td>row 3</td></tr>
</tbody>
</table>
</body>
</html>
EOS
expected = 4
count = 0
while true
count += 1
rows = Nokogiri::HTML(html).search('table#some_id tr').size
puts "got #{rows} rows, expected #{expected} on try #{count}" unless rows == expected
break unless rows == expected
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment