我试图从雅虎财经导入谷歌表中的股票实时价格,实时交易量和平均交易量,但不确定要使用的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)
以下是需要的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)