hpricot:An Hpricot Showcase:Hpricot Challenge:Getting a hold of malformed data that isn’t in an element.
まんま
require "hpricot" X =<<EOS <tr><td class="oreinfoleft"><b class=ul>Veldspar</b><br> <b>Units per batch:</b> 333<br> <b>Volume:</b> 0.1<br> <b>Cargo per batch:</b> 33.33 <td class="oreinforight"><b>Minerals:</b> Tritanium 100%<br> <b>Variations:</b> Concentrated Veldspar (+5%), Dense Veldspar (+10%)<br> <b>Found in:</b> 1.0<br> <font class=comment>Veldspar has the best cargo/mineral rate for tritanium</font> </tr> EOS doc = Hpricot(X) tdvalue = doc.search("//td[@class='oreinfoleft]'").inner_html volume = tdvalue.match(/Volume:<\/b>(.*)<br/) puts volume[1]
で、
0.1