我正在尝试针对tr
外部表中的表。外部表的第一个tr
包含一个table
带有标识表数据的图像。有几个带有不同图像的外部表,每种数据类型都有一个。我可以使用 Nokogiri 定位图像
page.css('table tr table tr img[@src="images/bicycyles.gif"]')
我想获取位于tr
外部表第三个表中的数据。我可以使用页面上的所有数据
page.css('table[bgcolor="#FFFFFF"] tr[valign="top"]')
但这也会从其他数据类型中提取数据(例如,在“cars.gif”下)。
我怎样才能结合这些搜索来只找到自行车数据?我基本上想说“从tr
withvalign=top
中提取文本table
with bgcolor=#ffffff
,这是tr
包含img src=bicycles.gif
这是 HTML 的示例:
<!-- Outer Table -->
<table>
<tr>
<td><img src="images/spacer.gif" width="1" height="10" /></td>
</tr>
<tr>
<td>
<table>
<tr>
<!-- Info must have this particular image preceding it -->
<td><img src="images/bicycle.gif" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td><img src="images/spacer.gif" width="100" height="10" /></td>
</tr>
<tr>
<td>
<table width="532">
<tr>
<td>Info</td>
</tr>
</table>
<table bgcolor="#FFFFFF">
<tr valign="top">
<!-- The info I want to extract -->
<td>Bicycle Name</td>
</tr>
</table>
</td>
</tr>
<!-- More trs with different data types -->
</table>