<p>I just found a great way to find a node in HTML using nokogiri. We need to get data from a table, inside a web page, that does not have any HTML/CSS identification (class, id, etc). So the first option was to "count" the rows and columns in the table to get to the data, not practical, I know, but it was the first attempt.</p><p>Then I found this: </p><pre><code class="language-ruby">url = "put your http address here"
doc = Nokogiri::HTML(open(url))
tr = doc.search "[text()*='some-text-that-identify-the-data-you-are-looking']"</code></pre><p>The first two lines I think are self explanatory. The third line does the magic of search inside all the document a text that "uniquely" identify the data we are looking for, or at least a nearby cell that allow us to access the cell that contains the data we are looking for.</p>
Get New Tutorials Delivered to Your Inbox
New tutorials will be sent to your Inbox once a week.