来自 FinViz 的财务数据使用 IMPORTHTML

问题描述

我正在尝试导出财务数据 - 例如净收入 - 在此页面上使用 FINVIZ:https://elite.finviz.com/quote.ashx?t=A&ty=c&p=d&b=1

我可以使用以下公式从此页面获取其他信息: =index(IMPORTHTML("http://finviz.com/quote.ashx?t="& $A2,"table",8),3,4) 使用 GOOGLE 表格

这不适用于财务信息,因为我无法确定表号是什么。

感谢您的帮助。

解决方法

我在这里回答您的评论问题,因为它有一个在 google 应用程序脚本中使用 json 的脚本示例

function growthEstimate(code){
  var url='https://finance.yahoo.com/quote/'+code+'/analysis'
  var source = UrlFetchApp.fetch(url).getContentText()
  var jsonString = source.match(/(?<=root.App.main = ).*(?=}}}})/g) + '}}}}'
  var data = JSON.parse(jsonString)
  return data.context.dispatcher.stores.QuoteSummaryStore.earningsTrend.trend[4].growth.fmt
}
function testGrowth(){
  Logger.log(growthEstimate('AAPL'))
}