Reputation: 341
<th><span class="sic_edu_series_popup {keyword : 'EPS_STOCK'}">EPS</span>
(SGD) <sup class="sic_legend">a
, j
</sup></th>
<td><strong>1.89766</strong></td>
<th><span class="sic_edu_series_popup {keyword : 'TRAILING_EPS_STOCK'}">Trailing EPS</span>
(SGD) <sup class="sic_legend">e</sup></th>
<td><strong>1.87198</strong></td>
<th><span class="sic_edu_series_popup {keyword : 'NAV_STOCK'}">NAV</span>
(SGD) <sup class="sic_legend">b</sup></th>
<td><strong>18.5449</strong></td>
</tr>
I am trying to extract data for 'Trailing EPS' to get data '1.87198'. There are many data with this format with different name, like EPS, ROE and etc
tree.xpath('//th[contains(normalize-space(span), "EPS")]/sup[@class = "sic_legend"]/td/text()')
I get nothing out from it.
Upvotes: 2
Views: 60
Reputation: 474241
The td
element is not a child of the sup
element. Use the fact that th
and td
are siblings:
//th[contains(span, "EPS")]/following-sibling::td/strong/text()
Upvotes: 3