XPath查询使用importxml提取Google表格中的当前价格,数量和平均交易量

问题描述 投票:0回答:1

我试图从雅虎财经导入谷歌表中的股票实时价格,实时交易量和平均交易量,但不确定要使用的XPath。

例如,对于URL

https://sg.finance.yahoo.com/quote/AMZN

under summary tab:
realtime price: 1910.21
volume: https://sg.finance.yahoo.com/quote/AMZN
avg. volume: 4,406,091

在这里我试图修改下面的代码但不确定XPath

=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/AMZN","//div[@id='quote-header-info']/div[last()]/div[1]"),1)
xpath google-sheets yahoo-finance google-sheets-importxml
1个回答
1
投票

以下是需要的3行。

实时价格

=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/AMZN","(//div[@id='quote-header-info']/div[last()]/div[1]//span)[1]"),1)

体积:

=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/AMZN","//td[@data-test='TD_VOLUME-value']/span"),1)

平均:

=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/AMZN","//td[@data-test='AVERAGE_VOLUME_3MONTH-value']/span"),1)
© www.soinside.com 2019 - 2024. All rights reserved.