<fieldset class="attachmentTable large"><legend>SMF</legend>
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td>
<a href="
/aems/file/test.html">
</a>
</td>
<td>
foo
</td>
</tr>
</table>
</fieldset>
<fieldset class="attachmentTable large"><legend>tax</legend>
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td>
<a href="
/relf/file/test.html">
</a>
</td>
<td>
foo
</td>
</tr>
</table>
</fieldset>
我有一个来自网页的html源代码,上面给出了部分内容。现在我只想在HREF
时获取<legend>tax</legend>
值?所以你们可以帮助我吗?
答案 0 :(得分:1)
我愿意:
page.search('legend[text()="tax"] + table a').each do |a|
puts a[:href]
end