[英]Yahoo Finance: working Google Sheets formula to check the Float
I want a formula to fetch the Float of eg BEKB.BR https://finance.yahoo.com/quote/BEKB.BR/key-statistics?p=BEKB.BR it's 36.45M Formula's like =index(IMPORTHTML("http://finance.yahoo.com/q/ks?s="& BEKB.BR"+Key+Statistics","table", 2), 4, 2) or the ticker in cell A27: =index(IMPORTHTML("http://finance.yahoo.com/q/ks?s="& $A$27&"+Key+Statistics","table", 2), 4, 2) don't give a result.我想要一个公式来获取浮点数,例如 BEKB.BR https://finance.yahoo.com/quote/BEKB.BR/key-statistics?p=BEKB.BR它是 36.45M 公式就像 =index(IMPORTHTML("http ://finance.yahoo.com/q/ks?s="& BEKB.BR"+Key+Statistics","table", 2), 4, 2) 或单元格 A27 中的代码:=index(IMPORTHTML( "http://finance.yahoo.com/q/ks?s="& $A$27&"+Key+Statistics","table", 2), 4, 2) 不给出结果。 Thanks for your help.谢谢你的帮助。
The IMPORTHTML()
and IMPORTXML()
functions don't fetch this page in a way I don't understand why. IMPORTHTML()
和IMPORTXML()
函数不会以我不明白为什么的方式获取此页面。
You can use URLFetchApp in Google Apps Script instead.您可以改用 Google Apps 脚本中的 URLFetchApp。
function fetch() {
url = "https://finance.yahoo.com/quote/BEKB.BR/key-statistics?p=BEKB.BR"
var response = UrlFetchApp.fetch(url).getContentText()
var index = response.indexOf('8</sup>')
var subst = response.substr(index,300)
var float = subst.match(/(?<=reactid="[0-9]+">)[^<]+/)[0]
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet()
sheet.getRange('A1').setValue(float)
}
Here is a working sample. 这是一个工作示例。 When you click on the button it writes the Float value to A1 cell.当您单击按钮时,它会将 Float 值写入 A1 单元格。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.