Google 表格:来自 Yahoo Finance 的 IMPORTXML [英] Google Sheet: IMPORTXML from Yahoo Finance

查看:34
本文介绍了Google 表格:来自 Yahoo Finance 的 IMPORTXML的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从雅虎财经导入当前股票价格.我使用了一些网站上的公式,它部分有效.我只知道如何告诉它查找特定查询,它对我需要的其他一些数据点工作正常,但价格更改查询从

I'm trying to import current stock price from yahoo finance. I used a formula from some website and it partially work. I only know how to tell it to look for a specific query and it worked fine for some other data point I need but the price change query changes from

"Fw(500) Pstart(10px) Fz(24px) C($dataRed)" 

"Fw(500) Pstart(10px) Fz(24px) C($dataGreen)" 

取决于当天的价格是上涨还是下跌.

depending if the price is up or down for the day.

如何修改我在下面使用的公式以使用或"?运营商在这种情况下?这样无论当天股票是上涨还是下跌,它都会拉低价格.谢谢!

How do I modify the formula I'm using below to use the "or" operator in this case? so that it will pull the price down whether the stock is up or down for the day. Thanks!

我使用的公式:=IMPORTXML("https://finance.yahoo.com/quote/IBM","//span[@class='Fw(500) Pstart(10px) Fz(24px) C($dataRed)']")

推荐答案

我注意到其他答案对我不起作用(它们可能在过去有效),因此我决定发布此解决方案.只需将代码放在单元格 A1 中,并将下面的一个或两个公式放在其他地方.

I noticed the other answers did not work for me (they may have worked in the past), so I decided to post this solution. Just put the ticker in cell A1 and one or both of the below formulas somewhere else.

价格:

=IFNA(VALUE(IMPORTXML("https://finance.yahoo.com/quote/" & A1, "//*[@class=""D(ib) Mend(20px)""]/span[1]")))

变化:

=IFNA(VALUE(REGEXEXTRACT(IMPORTXML("https://finance.yahoo.com/quote/" & A1,"//*[@class=""D(ib) Mend(20px)""]/span[2]"), "^.*?\s")))

这篇关于Google 表格:来自 Yahoo Finance 的 IMPORTXML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆