我有轉個股財務報表(損益表,資產負債表,現金流量)從雅虎金融到Excel中的VBA代碼,我已經使用了一段時間現在,但似乎雅虎已經改變了鏈接或東西。有人可以幫助我重新鏈接鏈接,以便編碼再次將拉動的信息從雅虎轉移到Excel嗎?下面是編碼股票從雅虎財務報表不再transferrinf脫穎而出
子FinancialStatements() 昏暗的股票作爲字符串 昏暗urlend作爲字符串
Application.ScreenUpdating = False ticker = Sheets("inputs").Cells(2, 1) If Sheets("Inputs").Shapes("Check Box 14").ControlFormat.Value = 1 Then urlend = "&annual" Else: urlend = "" End If Sheets("Income Statement").Select Cells.Clear If Sheets("Inputs").Shapes("Check Box 11").ControlFormat.Value = 1 Then ' With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://finance.yahoo.com/q/is?s=" & ticker & "" & urlend & "", Destination:=Range("$A$1") _ ) .Name = "is?s=MSFT&annual" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlSpecifiedTables .WebFormatting = xlWebFormattingNone .WebTables = "9" .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With End If Sheets("Balance Sheet").Select Cells.Clear If Sheets("Inputs").Shapes("Check Box 12").ControlFormat.Value = 1 Then ' With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://finance.yahoo.com/q/bs?s=" & ticker & "" & urlend & "", Destination:=Range("$A$1") _ ) .Name = "is?s=MSFT&annual" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlSpecifiedTables .WebFormatting = xlWebFormattingNone .WebTables = "9" .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With End If Sheets("Cash Flows").Select Cells.Clear If Sheets("Inputs").Shapes("Check Box 13").ControlFormat.Value = 1 Then ' With ActiveSheet.QueryTables.Add(Connection:= _ "URL;http://finance.yahoo.com/q/cf?s=" & ticker & "" & urlend & "", Destination:=Range("$A$1") _ ) .Name = "is?s=MSFT&annual" .FieldNames = True .RowNumbers = False .FillAdjacentFormulas = False .PreserveFormatting = True .RefreshOnFileOpen = False .BackgroundQuery = True .RefreshStyle = xlInsertDeleteCells .SavePassword = False .SaveData = True .AdjustColumnWidth = True .RefreshPeriod = 0 .WebSelectionType = xlSpecifiedTables .WebFormatting = xlWebFormattingNone .WebTables = "9" .WebPreFormattedTextToColumns = True .WebConsecutiveDelimitersAsOne = True .WebSingleBlockTextImport = False .WebDisableDateRecognition = False .WebDisableRedirections = False .Refresh BackgroundQuery:=False End With End If Application.ScreenUpdating = True End Sub
-1
A
回答
0
我認爲雅虎改變了它的網站最近。只需檢查您的網址,然後先開始工作即可。
http://finance.yahoo.com/quote/IBM/financials?p=IBM
當你知道這是正確的,工程周圍的一切是其他。
這是一個適合我的解決方案。這將單元格A2中的多個代號(列表在工作表中)的數據導入數組的末尾。
Sub Dow_HistoricalData()
Dim xmlHttp As Object
Dim TR_col As Object, TR As Object
Dim TD_col As Object, TD As Object
Dim row As Long, col As Long
ThisSheet = ActiveSheet.Name
Range("A2").Select
Do Until ActiveCell.Value = ""
Symbol = ActiveCell.Value
Sheets(ThisSheet).Select
Sheets.Add
Set xmlHttp = CreateObject("MSXML2.XMLHTTP.6.0")
' http://finance.yahoo.com/quote/" & Symbol & "/financials?ltr=1
xmlHttp.Open "GET", "http://finance.yahoo.com/quote/" & Symbol & "/financials?ltr=1", False
xmlHttp.setRequestHeader "Content-Type", "text/xml"
xmlHttp.send
Dim html As Object
Set html = CreateObject("htmlfile")
html.body.innerHTML = xmlHttp.ResponseText
Dim tbl As Object
Set tbl = html.getElementById("Lh(1.7) W(100%) M(0)")
'
row = 1
col = 1
Set TR_col = html.getelementsbytagname("TR")
For Each TR In TR_col
Set TD_col = TR.getelementsbytagname("TD")
For Each TD In TD_col
Cells(row, col) = TD.innerText
col = col + 1
Next
col = 1
row = row + 1
Next
Sheets(ActiveSheet.Name).Name = Symbol
Sheets(ThisSheet).Select
ActiveCell.Offset(1, 0).Select
Loop
End Sub
這是我的設置的屏幕快照。
相關問題
- 1. retriving股票報價與雅虎財經
- 2. 從雅虎財務獲取股票報價
- 3. 做過雅虎財務api股票回報股票期權數據?
- 4. 從雅虎財務獲取股票圖表
- 5. 雅虎財經API全部股票?
- 6. 雅虎財經商品股票報價PHP
- 7. 從開始和結束日期的雅虎財務獲取股票報價
- 8. 如何使用雅虎財務獲得RealTime股票價格
- 9. 雅虎股票API格式
- 10. 如何使用雅虎財務API檢索一個多月的股票報價?
- 11. python2.7:從雅虎財經獲得股票數據與pandas_datareader錯誤
- 12. 從雅虎股票網站解析股票推薦評級
- 13. 雅虎財務api圖表
- 14. fgetcsv不適用於雅虎股票csv?
- 15. 從雅虎財務中檢索每隻股票的歷史收盤價?
- 16. XSD雅虎財務
- 17. 雅虎財經REST API的歷史股票數據
- 18. 雅虎財經API股票過去的價值
- 19. 如何獲取雅虎財經股票數據?
- 20. 雅虎財經流星套餐,股票代碼難度
- 21. 雅虎財經搜索股票代碼API /方法
- 22. 雅虎財經股票代碼僅適用於JSFiddle
- 23. 雅虎財經股票數據/類PagesController <ApplicationController MET_AKEY
- 24. 雅虎財務API實時報價
- 25. 使用javascript以json格式獲取雅虎財經的股票報價
- 26. 雅虎股票官方庫存api
- 27. 如何讓雅虎財務YQL查詢超過1年的股票數據?
- 28. 在股票數據請求被拒絕後繼續查詢雅虎財務
- 29. Windows RT /通用應用程序,檢查來自雅虎財務的股票
- 30. 雅虎財務API錯誤
您可能想問問雅虎,或查看他們的文檔? – criticalfix