如何在“<legend> tax </legend>时获取`HREF`值?

时间:2013-01-22 22:23:35

标签: ruby mechanize selenium-webdriver

<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>值?所以你们可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

我愿意:

page.search('legend[text()="tax"] + table a').each do |a|
  puts a[:href]
end