¥»©«³Ì«á¥Ñ Scott090 ©ó 2017-11-12 17:01 ½s¿è
'±²°Êºô¶
'''' i ȤӤp¡Aºô¶¸ê®Æ·|¨Ó¤£¤Î¶i¨Ó¡F¤Ó¤j·|®ö¶O®É¶¡
'''' ¦³¦ó¤èªk¥i¥Hª¾¹D¸ê®Æ¤w¶i¨Ó»ô¥þ¦Ó°±¤î¡F©Î¨ä¥L¤è¦¡¨ú¥N¥»¤èªk?
i = 0
While i < 50
.Document.Parentwindow.scrollby 0, 10000 'Move,Scroll IE window down to bottom
i = i + 1
Wend
½Ð°Ý¨º¤@¦ì«e½úÀ°¦£? ¥ýÁÂÁÂ
¥H¤Uªº¨Ò¤l¬O¸ê®Æªºªøµu¦h¹è¨ú¨M©ó¤é´Á´Á¶¡ªºªøµu¡A¦p¦ó°µ·|¤ñ¸û¦³®Ä²v?- '¨Ï¥Î ie,Application ª«¥ó
- '±q finance.Yahoo.com¨ú±o¾ú¥v¸ê®Æ
- '
- Sub getHistoricalData()
- Dim Code
- Code = "AAPL"
- Const mysteryNum = 2209190400#
- Dim ie, DATAar, A$, yyDate
- Dim URL As String
- Dim StartDate, EndDate, timer, tt As Date
- Dim Table As Object, oDoc As Object
- Dim i%, j%, k%
-
- StartDate = "1999/1/2" '¶}©l¤é´Á
- EndDate = Date 'µ²§ô¤é´Á¡A¹w³]¬°¤µ¤Ñ
-
- 'Âà´«¬°¬íÄÁ¼Æ¦r
- StartDate = DateValue(StartDate) * 86400 - mysteryNum
- EndDate = DateValue(EndDate) * 86400 - mysteryNum
-
- Set ie = CreateObject("InternetExplorer.Application")
-
- With ie
- Application.StatusBar = "¥´¶}ºô¶¡Aµ¥«Ý¸ê®Æ³Æ»ô ....."
- URL = "https://finance.yahoo.com/quote/" & Code & "/history?period1=" & StartDate & "&period2=" & EndDate & "&interval=1d&filter=history&frequency=1d"
- .Visible = True ' False 'Åã¥Ü IE§_?
- .navigate URL
- Application.Wait Time + #12:00:04 AM# 'µ¥Ôºô¶4¬íÄÁ
- tt = Time + #12:00:05 AM#
- Do While (.busy Or .readyState <> 4) And Time < tt
- DoEvents
- Loop
-
- '±²°Êºô¶
- '''' i ȤӤp¡Aºô¶¸ê®Æ·|¨Ó¤£¤Î¶i¨Ó¡F¤Ó¤j·|®ö¶O®É¶¡
- '''' ¦³¦ó¤èªk¥i¥Hª¾¹D¸ê®Æ¤w¶i¨Ó»ô¥þ¦Ó°±¤î¡F©Î¨ä¥L¤è¦¡¨ú¥N¥»¤èªk?
- i = 0
- While i < 50
- .Document.Parentwindow.scrollby 0, 10000 'Move,Scroll IE window down to bottom
- i = i + 1
- Wend
-
- Application.StatusBar = "¨úºô¶¸ê®Æ¤¤ .... "
- Set oDoc = .Document.getElementsByTagName("TABLE")(1)
-
- ActiveSheet.Cells.Clear
- ReDim DATAar(oDoc.Rows.Length - 1, 7)
-
- For i = 0 To oDoc.Rows.Length - 2
- For j = 0 To 6
- On Error Resume Next
- DATAar(i + 1, j + 1) = oDoc.Rows(i).Cells(j).innertext
- If j = 0 And i <> 0 Then
-
- '''' yyDate = CDate("Oct 01, 2017")
- A = DATAar(i + 1, j + 1)
- A = Mid(A, 2, 3) & " " & Mid(A, 8, 2) & ", " & Right(A, 4)
- yyDate = CDate(A)
- DATAar(i + 1, j + 1) = yyDate
-
- End If
- Next
- Next
- Application.StatusBar = "¸ê®Æ²¾¨ìExcel ¤u§@ªí ....."
- ActiveSheet.Cells(1, 1).Resize(UBound(DATAar), 7).Value = DATAar
- Columns("A:A").NumberFormatLocal = "yyyy/mm/dd"
- Columns("G:G").NumberFormatLocal = "#,##0_)"
- .Quit
- End With
- Application.StatusBar = "¸ê®Æ¤U¸ü§¹¦¨ ....... "
- Application.Wait Time + #12:00:02 AM#
- Application.StatusBar = False
-
- End Sub
½Æ»s¥N½X |