我有一个我在金融市场寻找的特定信息,不幸的是当前的过滤器不允许我这样做。我有一个替代谷歌表,我可以直接进入每个股票,并单独检查。我可以使用importhtml,并且在某种程度上它可以工作,但我想使用importXML,以防表的位置发生变化。
实施例 我在这里使用的网站是“金融时报”
这是页面来源的片段:
<span>Sectors</span><i class="o-ft-icons-icon o-ft-icons-icon--arrow-down"></i>
<ul class="mod-ui-tab-row mod-ui-tab-row--dropdown" role="tablist">
<li aria-controls="sectors-panel" aria-selected="true" class="mod-ui-tab mod-ui-tab__module-header" role="tab">Sectors</li>
<li aria-controls="regions-panel" aria-selected="false" class="mod-ui-tab mod-ui-tab__module-header" role="tab">Regions</li>
</ul>
<div class="mod-module__content">
<div aria-hidden="false" class="mod-ui-tab-content" id="sectors-panel" role="tabpanel">
<div>
<div aria-hidden="false" class="mod-weightings__sectors">
<div class="mod-weightings__sectors__chart">
<div class="mod-weightings__sectors__chart--dynamic mod-ui-chart--dynamic"></div>
</div>
<div class="mod-weightings__sectors__table">
<table class="mod-ui-table mod-ui-table--colored">
<thead>
<tr>
<th class="mod-ui-table__header--text">Sector</th>
<th>% Net assets</th>
<th>Category average</th>
</tr>
</thead>
<tbody>
<tr>
<td class="mod-ui-table__cell--colored"><span class="mod-ui-table__cell--colored__wrapper" style="border-color:#27757B;">Technology</span></td>
<td>88.04%</td>
<td>73.78%</td>
</tr>
<tr>
<td class="mod-ui-table__cell--colored"><span class="mod-ui-table__cell--colored__wrapper" style="border-color:#EEA45F;">Financial Services</span></td>
<td>8.38%</td>
<td>3.74%</td>
</tr>
<tr>
<td class="mod-ui-table__cell--colored"><span class="mod-ui-table__cell--colored__wrapper" style="border-color:#94826B;">Industrials</span></td>
<td>2.72%</td>
<td>6.28%</td>
</tr>
<tr>
<td class="mod-ui-table__cell--colored"><span class="mod-ui-table__cell--colored__wrapper" style="border-color:#EED485;">Consumer Cyclical</span></td>
<td>0.67%</td>
<td>5.98%</td>
</tr>
<tr>
<td class="mod-ui-table__cell--colored"><span class="mod-ui-table__cell--colored__wrapper" style="border-color:#A6A371;">Healthcare</span></td>
<td>0.00%</td>
<td>2.93%</td>
</tr>
<tr>
<td class="mod-ui-table__cell--colored"><span class="mod-ui-table__cell--colored__wrapper" style="border-color:#819E9A;">Communication Services</span></td>
<td>0.00%</td>
<td>2.36%</td>
</tr>
<tr>
<td class="mod-ui-table__cell--colored"><span class="mod-ui-table__cell--colored__wrapper" style="border-color:#746E7F;">Real Estate</span></td>
<td>0.00%</td>
<td>0.17%</td>
</tr>
<tr>
<td class="mod-ui-table__cell--colored"><span class="mod-ui-table__cell--colored__wrapper" style="border-color:#73A5C3;">Consumer Defensive</span></td>
<td>0.00%</td>
<td>0.08%</td>
</tr>
</tbody>
</table>
</div>
<div class="mod-disclaimer">
As of Dec 19 2017. Sectors weighting is calculated using only long position holdings of the portfolio.
</div>
</div>
</div>
</div>
</div>
我希望获得金融服务之后的第一个值(%)或扇区表中的任何名为finance的东西。在这种情况下,该值将为8.38%
答案 0 :(得分:1)
您正在寻找的xpath应该是这样的:
//span[text()="Financial Services"]/parent::td/following-sibling::td[1]/text()
Financial Services
的范围。text()
)