I am trying to analyze the contents of a website using mechanization, and I am stuck at a certain point. The content I want to parse is inside the li tag and is not always in the same order.
Suppose we have the following, where the order of the li tags is not always the same and several times some may not even be at all.
<div class="details"> <ul> <li><span>title 1</span> ": here are the details"</li> <li><span>title 2</span> ": here are the details"</li> <li><span>title 3</span> ": here are the details"</li> <li><span>title 4</span> ": here are the details"</li> </ul> </div>
I want to get only those li details where the span text is, for example, title 3 . I did the following, which gives me information from the first li :
puts page.at('.details').at('span', :text => "title 3").at("+ *").text
Is there a way to do what I want to use mechanize, or use other tools?
css ruby mechanize
gkaran89
source share