【发布时间】:2016-12-06 13:32:32
【问题描述】:
以前使用 python 工作 n xpath 并且从网页中提取数据很健壮。现在我需要对同一个网页使用 YQL,但它不够健壮。
我想得到的是 1. 最后(澳元) 2. 关闭 3.收盘(%) 4. 累计成交量 来自https://www.shareinvestor.com/fundamental/factsheet.html?counter=TPM.AX 我在python中使用的xpath如下:
xpath('//td[contains(., "Last")]/strong/text()')
xpath('//td[contains(., "Change")]/strong/text()')[0]
xpath('//td[contains(., "Change (%)")]/strong/text()')
xpath('//td[contains(., "Cumulative Volume")]/following-sibling::td[1]/text()')
部分html在这里
<tr>
<td rowspan="2" class="sic_lastdone">Last (AUD): <strong>6.750</strong></td>
<td class="sic_change">Change: <strong>-0.080</strong></td>
<td>High: <strong>6.920</strong></td>
<td rowspan="2" class="sic_remarks">
Remarks: <strong>-</strong>
</td>
</tr>
<tr>
<td class="sic_change">Change (%): <strong>-1.17</strong></td>
<td>Low: <strong>6.700</strong></td>
</tr>
<tr>
<tr>
<td>Cumulative Volume (share)</td>
<td class='sic_volume'>3,100,209</td>
<td>Cumulative Value</td>
<td class='sic_value'></td>
</tr>
但是当我想申请YQL时,它没有工作。它只适用于
select * from html where
url="https://www.shareinvestor.com/fundamental/factsheet.html?counter=TPM.AX"
and xpath="//td/strong"
它将获取大量数据。我想要一个特定的数据并且需要健壮,以便网页的更改,我的查询仍然有效。如何获得健壮的 YQL xpath?
【问题讨论】: