Trying to use IMPORTHTML or IMPORTXML to get price value from https://finance.yahoo.com/quote/GSPX.L/ in Google Sheets

huangapple go评论64阅读模式
英文:

Trying to use IMPORTHTML or IMPORTXML to get price value from https://finance.yahoo.com/quote/GSPX.L/ in Google Sheets

问题

我正在尝试使用IMPORTHTML或IMPORTXML从https://finance.yahoo.com/quote/GSPX.L/获取价格值。

或者实际上从任何能提供相对最新数据的网站获取。

我过去可以使用GOOGLEFINANCE公式获得该值,但最近对一些股票(而非所有股票)已经停止起作用。

我曾经成功地使用IMPORTHTML来获取morningstar.co.uk上一些指数基金的值,但GSPX.L的页面布局不同。我尝试使用IMPORTXML和完整的XPath,但似乎不起作用。据我了解,IMPORTXML非常挑剔。

我只需要这一个数字!对如何获得它有任何见解,但最好是一些更系统化的方法,以便将来可以使用。

英文:

I'm trying to use IMPORTHTML or IMPORTXML to get price value from https://finance.yahoo.com/quote/GSPX.L/

or in fact from any site that will give me a relatively up-to-date number.

I used to be able to get the value using the GOOGLEFINANCE formula, but that's recently stopped working for a few tickers (not all!)

I've managed to get IMPORTHMTL to work in the past with morningstar.co.uk for some index funds, but the page layout is different with GSPX.L. I've tried using the Full XPath with IMPORTXML but that doesn't seem to work and as far as I understand it IMPORTXML is extremely finnicky.

I just need this one number! Any insight into how to get it, but ideally something more systematic that I can use in the future?

答案1

得分: 1

I can provide the translated content as requested:

如果我没弄错的话,您想要获取的是那个页面上的7.03价格数值。我认为页面上有一些东西阻止了Excel和Google Sheets公式的运行,因此不可能使用您提供的那个网站。

相反,我能够从markets.ft.com获取到它。您可以使用以下公式来获取完全相同的数字:

=IMPORTXML("https://markets.ft.com/data/etfs/tearsheet/summary?s=GSPX:LSE:GBP", "/html/body/div[3]/div[2]/section[1]/div/div/div[1]/div[2]/ul/li[1]/span[2]")

参考资料:

英文:

If I am not mistaken, what you want to get is the 7.03 price value from that page. I think there is something on the page blocking Excel and Google Sheets formulas from running on it so it would not be possible to use that site you provided.

Instead I was able to get it from markets.ft.com. You can use the following formula to get that exact same number:

=IMPORTXML("https://markets.ft.com/data/etfs/tearsheet/summary?s=GSPX:LSE:GBP", "/html/body/div[3]/div[2]/section[1]/div/div/div[1]/div[2]/ul/li[1]/span[2]")

Trying to use IMPORTHTML or IMPORTXML to get price value from https://finance.yahoo.com/quote/GSPX.L/ in Google Sheets

References:

huangapple
  • 本文由 发表于 2023年5月6日 22:36:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76189460.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定