xpath从第二页抓取数据

时间:2017-01-14 16:47:01

标签: html xpath google-sheets

我正在尝试从此网页抓取数据:http://webfund6.financialexpress.net/clients/zurichcp/PortfolioPriceTable.aspx?SchemeID=33,我特别需要基金号码26的数据。

使用此地址(资金编号1-25)从第一页获取数据没有问题,但是我的地狱无法从第二页中删除任何内容。有人可以帮忙吗?

谢谢!

以下是我使用的代码:在Google表格中:

= IMPORTXML( “http://webfund6.financialexpress.net/clients/zurichcp/PortfolioPriceTable.aspx?SchemeID=33”,“/ HTML /体/形式[@ ID = '的MainForm'] /表/ TR / TD /格[@ ID = '主'] /格[@id = 'tabResult'] /格[@ ID = '价格'] /表/ THEAD / TR [26] / TD [@类= '中心'] [1]“)

2 个答案:

答案 0 :(得分:0)

要获取第二页,请将& PgIndex = 2添加到您的网址。然后将/ table / thead / tr [26]调整为/ table / thead / tr [2]。结果是:

=IMPORTXML("http://webfund6.financialexpress.net/clients/zurichcp/PortfolioPriceTable.aspx?SchemeID=33&PgIndex=2","/html/body/form[@id='MainForm']/table/tr/td/div[@id='main']/div[@id='tabResult']/div[@id='Prices']/table/thead/tr[2]/td[@class='Center'][1]")

答案 1 :(得分:0)

你可以做两件事 - 一件是将PgIndex=2附加到你的URL的末尾,然后你也可以大大简化你的xpath:

//*[@id='Prices']//tr[2]/td[2]

这专门抓取表格中的第二行(tr表示表格行),以绕过标题行,然后抓取第二个字段,即表格数据单元格。

=IMPORTXML("http://webfund6.financialexpress.net/clients/zurichcp/PortfolioPriceTable.aspx?SchemeID=33&PgIndex=2","//*[@id='Prices']//tr[2]/td[2]")

enter image description here