【问题标题】:crawl realtime google finance price抓取实时谷歌金融价格
【发布时间】:2017-11-28 09:16:33
【问题描述】:

我想创建一个类似于 Bloomberg 的启动板的小型 Excel 表格,用于监控实时股票市场价格。到目前为止,在所有可用的免费数据源中,我只发现 Google Finance 提供了我需要的交易所列表的实时价格。谷歌金融的问题是他们已经关闭了他们的金融 API。我正在寻找一种方法来帮助我以编程方式检索我在下表中圈出的实际价格,以便在我的 Excel 中实时更新。

到目前为止,我一直在四处寻找,但无济于事。我在这里读了一些帖子: How does Google Finance update stock prices? 但答案中建议的方法指向检索图表中的时间序列数据,而不是我需要的实时更新价格部分。我一直在 chrome 的检查中检查网页的网络通信,没有发现任何返回我需要的实时价格部分的请求。任何帮助是极大的赞赏。一些示例代码(可以是 VBA 以外的其他语言)将非常有益。感谢大家 !

【问题讨论】:

    标签: ajax vba real-time google-finance


    【解决方案1】:

    有很多方法可以做到这一点:VBA、VB、C# R、Python 等。下面是从雅虎财经下载统计数据的方法。

    Sub DownloadData()
    
    Set ie = CreateObject("InternetExplorer.application")
    
    With ie
        .Visible = True
        .navigate "https://finance.yahoo.com/quote/AAPL/key-statistics?p=AAPL"
    
        ' Wait for the page to fully load; you can't do anything if the page is not fully loaded
        Do While .Busy Or _
            .readyState <> 4
            DoEvents
        Loop
    
        ' Set a reference to the data elements that will be downloaded. We can download either 'td' data elements or 'tr' data elements.  This site happens to use 'tr' data elements.
        Set Links = ie.document.getElementsByTagName("tr")
        RowCount = 1
    
        ' Scrape out the innertext of each 'tr' element.
        With Sheets("DataSheet")
            For Each lnk In Links
                .Range("A" & RowCount) = lnk.innerText
                RowCount = RowCount + 1
            Next
        End With
    End With
    MsgBox ("Done!!")
    
    End Sub
    

    我会让你自己去寻找其他同样的技术。事情,例如,R 和 Prthon 可以做完全相同的事情,虽然,脚本会与做这种工作的 VBA 脚本有点不同。

    【讨论】:

      猜你喜欢
      • 2011-08-03
      • 1970-01-01
      • 2018-08-07
      • 2018-01-27
      • 1970-01-01
      • 2010-11-21
      • 1970-01-01
      • 2018-04-27
      • 1970-01-01
      相关资源
      最近更新 更多