【问题标题】:Yahhoo Finance to get Growth Rate雅虎财经获得增长率
【发布时间】:2021-06-27 17:17:21
【问题描述】:

我正在关注this 以确定 aapl 5 年增长率并插入谷歌表格。它适用于计算基本股价,例如这个 =IMPORTXML("https://finance.yahoo.com/quote/AAPL?p=AAPL&.tsrc=fin-srch","//*[@id='quote- header-info']/div2/div1/div/span1")

但是,当使用相同的过程来计算 5 年增长率时(可以在 this 页面(和下图)上看到),该过程不起作用并且 google 表格会引发错误(找不到 URL 处的资源)。这是我使用的公式 =IMPORTXML("https://finance.yahoo.com/quote/Aapl/analysis","//*[@id='Col1-0-AnalystLeafPage-Proxy']/section/table[6 ]/tbody/tr[5]/td2")

知道为什么以及是否可能吗?

【问题讨论】:

    标签: google-sheets yahoo-finance


    【解决方案1】:

    我们受制于一家公司改变他们的网站,有时过去的工作会停止工作。我什至无法让第一个返回您所说的有效数据。

    查看我看到有人在此处发布的这张表,我不确定它是否具有您想要的特定统计信息。我也没有仔细研究过这张表,但它确实使用 json 和一个小脚本来发挥它的魔力。

    https://docs.google.com/spreadsheets/d/1_YfvUIvVLjCqKpGuWM3TYqT1HEco0UascTZcyR2fqjI/edit#gid=896982005

    请随意复制。

    【讨论】:

      【解决方案2】:

      如果您特别想要未来 5 年的增长:

      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 test(){
        Logger.log(growthEstimate('AAPL'))
      }
      

      【讨论】:

        猜你喜欢
        • 2017-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-06-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多