I'm working on a Ruby script that uses Nokogiri and CSS selectors. I'm trying to scrape some data from HTML that looks like this:
<h2>Title 1</h2>
(Part 1)
<h2>Title 2</h2>
(Part 2)
<h2>Title 3</h2>
(Part 3)
Is there a way to select from Part 2
only by specifying the text of the h2
elements that represent the start and end points?
The data of interest in Part 2
is a table with tr
and td
elements that don't have any class
or id
identifiers. The other parts also have tables I'm not interested in. Something like
page.css('table tr td')
on the entire page would select from all of those other tables in addition to the one I'm after, and I'd like to avoid that if at all possible.