0 xpath google-sheets yahoo-finance google-sheets-importxml
我正在尝试从 Yahoo Finance 导入 Google 表格中的股票实时价格、实时交易量和平均交易量,但不确定 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
Run Code Online (Sandbox Code Playgroud)
在这里我尝试修改下面的代码但不确定 XPath
=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/AMZN","//div[@id='quote-header-info']/div[last()]/div[1]"),1)
Run Code Online (Sandbox Code Playgroud)
这是需要的3行。
实时价格
=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/AMZN","(//div[@id='quote-header-info']/div[last()]/div[1]//span)[1]"),1)
Run Code Online (Sandbox Code Playgroud)
体积:
=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/AMZN","//td[@data-test='TD_VOLUME-value']/span"),1)
Run Code Online (Sandbox Code Playgroud)
平均数:
=INDEX(IMPORTXML("https://sg.finance.yahoo.com/quote/AMZN","//td[@data-test='AVERAGE_VOLUME_3MONTH-value']/span"),1)
Run Code Online (Sandbox Code Playgroud)