ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[µo°Ý] ºô­¶¸ê®Æ«Üªø¡A¦p¦ó¦³®Ä²v¦aª¾¹D¤w§¹¾ã¶i¨Ó

[µo°Ý] ºô­¶¸ê®Æ«Üªø¡A¦p¦ó¦³®Ä²v¦aª¾¹D¤w§¹¾ã¶i¨Ó

¥»©«³Ì«á¥Ñ 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?
  1. '¨Ï¥Î ie,Application ª«¥ó
  2. '±q finance.Yahoo.com¨ú±o¾ú¥v¸ê®Æ
  3. '
  4. Sub getHistoricalData()
  5.         Dim Code
  6.         Code = "AAPL"
  7.         Const mysteryNum = 2209190400#
  8.         Dim ie, DATAar, A$, yyDate
  9.         Dim URL As String
  10.         Dim StartDate, EndDate, timer, tt As Date
  11.         Dim Table As Object, oDoc As Object
  12.         Dim i%, j%, k%
  13.         
  14.         StartDate = "1999/1/2"            '¶}©l¤é´Á
  15.         EndDate = Date                          'µ²§ô¤é´Á¡A¹w³]¬°¤µ¤Ñ

  16.       'Âà´«¬°¬íÄÁ¼Æ¦r
  17.     StartDate = DateValue(StartDate) * 86400 - mysteryNum
  18.     EndDate = DateValue(EndDate) * 86400 - mysteryNum
  19.    
  20.    Set ie = CreateObject("InternetExplorer.Application")
  21.         
  22.     With ie
  23.             Application.StatusBar = "¥´¶}ºô­¶¡Aµ¥«Ý¸ê®Æ³Æ»ô ....."
  24.             URL = "https://finance.yahoo.com/quote/" & Code & "/history?period1=" & StartDate & "&period2=" & EndDate & "&interval=1d&filter=history&frequency=1d"
  25.             .Visible = True ' False                'Åã¥Ü IE§_?
  26.             .navigate URL
  27.             Application.Wait Time + #12:00:04 AM#                   'µ¥­Ôºô­¶4¬íÄÁ
  28.             tt = Time + #12:00:05 AM#
  29.             Do While (.busy Or .readyState <> 4) And Time < tt
  30.                 DoEvents
  31.             Loop
  32.             
  33.             '±²°Êºô­¶
  34. '''' i ­È¤Ó¤p¡Aºô­¶¸ê®Æ·|¨Ó¤£¤Î¶i¨Ó¡F¤Ó¤j·|®ö¶O®É¶¡
  35. ''''   ¦³¦ó¤èªk¥i¥Hª¾¹D¸ê®Æ¤w¶i¨Ó»ô¥þ¦Ó°±¤î¡F©Î¨ä¥L¤è¦¡¨ú¥N¥»¤èªk?
  36.             i = 0
  37.             While i < 50
  38.                 .Document.Parentwindow.scrollby 0, 10000 'Move,Scroll IE window down to bottom
  39.                 i = i + 1
  40.             Wend
  41.                         
  42.             Application.StatusBar = "¨úºô­¶¸ê®Æ¤¤ .... "
  43.             Set oDoc = .Document.getElementsByTagName("TABLE")(1)
  44.             
  45.             ActiveSheet.Cells.Clear
  46.             ReDim DATAar(oDoc.Rows.Length - 1, 7)
  47.             
  48.             For i = 0 To oDoc.Rows.Length - 2
  49.                     For j = 0 To 6
  50.                           On Error Resume Next
  51.                           DATAar(i + 1, j + 1) = oDoc.Rows(i).Cells(j).innertext
  52.                           If j = 0 And i <> 0 Then
  53.                           
  54.                           ''''    yyDate = CDate("Oct 01, 2017")
  55.                                 A = DATAar(i + 1, j + 1)
  56.                                 A = Mid(A, 2, 3) & " " & Mid(A, 8, 2) & ", " & Right(A, 4)
  57.                                 yyDate = CDate(A)
  58.                                 DATAar(i + 1, j + 1) = yyDate
  59.                                 
  60.                           End If
  61.                     Next
  62.             Next
  63.             Application.StatusBar = "¸ê®Æ²¾¨ìExcel ¤u§@ªí ....."
  64.             ActiveSheet.Cells(1, 1).Resize(UBound(DATAar), 7).Value = DATAar
  65.             Columns("A:A").NumberFormatLocal = "yyyy/mm/dd"
  66.             Columns("G:G").NumberFormatLocal = "#,##0_)"
  67.             .Quit
  68.     End With
  69.     Application.StatusBar = "¸ê®Æ¤U¸ü§¹¦¨ ....... "
  70.     Application.Wait Time + #12:00:02 AM#
  71.     Application.StatusBar = False
  72.    
  73. End Sub
½Æ»s¥N½X

¥»©«³Ì«á¥Ñ GBKEE ©ó 2017-11-14 15:24 ½s¿è

¦^´_ 1# Scott090
  1. Option Explicit
  2. Dim Sh As Worksheet
  3. Sub Ex_ºô­¶©³³¡()
  4.     Dim E As Object, Er As Integer
  5.     'Dim Timer As Date   'Timer ¬°vbaªº¤º«Ø¨ç¼Æ ,ÅܼƦWºÙºÉ¶q¤£­n¬Û¦P
  6.     Dim xTimer As Date
  7.     Application.DisplayStatusBar = True
  8.     Application.StatusBar = False
  9.     Set Sh = ActiveSheet
  10.     Sh.Cells.Clear
  11.     On Error GoTo EE
  12.     With CreateObject("InternetExplorer.Application")
  13.       '  .Visible = True
  14.         xTimer = Time
  15.         .Navigate "https://finance.yahoo.com/quote/AAPL/history?period1=915206400&period2=1505174400&interval=1d&filter=history&frequency=1d"
  16.         Do While .Busy Or .readyState <> 4: DoEvents: Application.StatusBar = "******  µ¥ ­Ô ºô ­¶ ¤U... " & Time:   Loop
  17.         Do
  18.              Application.StatusBar = "******  ¸ê®Æ ¤U¸ü¤¤..." & Application.Text(Time - xTimer, "   [S]¬í") & " ******"
  19.             .document.Parentwindow.scrollBy 0, 37900
  20.             Do While .Busy Or .readyState <> 4: DoEvents:            Loop
  21.             With .document.documentElement
  22.                 ' Debug.Print .scrollTop , .clientHeighT, .scrollHeight  '***­pºâ¥X 37900¬°³Ì¤j­È
  23.                 If .scrollTop + .clientHeighT = .scrollHeight Then Exit Do
  24.             End With
  25.             DoEvents
  26.         Loop
  27.         Set E = .document.ALL.TAGS("TABLE")(1)
  28.         Ep .document.ALL.TAGS("TABLE")(1).outerHTML
  29.         Application.StatusBar = "** [" & xTimer & " - " & Time & Application.Text(Time - xTimer, " ] , ­p [S]¬í") & " ,¤U¸ü ¦@ " & E.Rows.Length - 2 & " µ§¸ê®Æ §¹²¦ !! **"
  30.         .Quit        'Ãö³¬ºô­¶
  31.     End With
  32. Exit Sub
  33. EE:  'µ{¦¡¹B¦æ³t«×¤j©óie®Éªº±¹¬I
  34.     Application.StatusBar = "ºô­¶¿ù»~µ¥­Ô¤¤...."
  35.     Er = Er + 1
  36.     If Er >= 3 Then Stop
  37.     Application.Wait (Second(Now()) + 2)
  38.     Resume
  39. End Sub
  40. Private Sub Ep(S As String) ' A(A.Length - 1).outerHTML
  41.     With CreateObject("InternetExplorer.Application")
  42.         .Navigate "about:Tabs"
  43.        ' .Visible = True
  44.         .document.body.innerHTML = S
  45.         .ExecWB 17, 2       '  Select All
  46.         .ExecWB 12, 2       '  Copy selection
  47.         With Sh
  48.             .Activate
  49.            ' .Cells.Clear
  50.             .Range("A1").Select
  51.             .PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
  52.             .Range("A1").Select
  53.         End With
  54.         .Quit
  55.     End With
  56. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ Scott090 ©ó 2017-11-13 16:01 ½s¿è

¦^´_ 2# GBKEE


  ÁÂÁ  GBKEE ¤jªº«ü¾É
¬°Æ[¹îºô­¶¦æ¬°¯S©Ê±N¨âºØ¤èªk°µ¤@¤ñ¸û¡A°õ¦æµ²ªG¦p¤Uªí¡G
³]©w±ý¨ú¸ê®Æ´Á¶¡¡F¶}©l 1999/1/2¡A µ²§ô´Á¶¡ 2017/9/12       
Â^¨ú.JPG
2017-11-13 15:49


¨ä¤¤¤èªk¤G¨Ã¥¼§¹¾ãªº¨ú±o¸ê®Æ¡F
¤èªk¤@«hµø scrollby ªº°Ñ¼Æ¦Ó©w¡A³]¤p¤F¨ú¸ê®Æ¤£§¹¾ã¡A³]¤j¤F¸ê®Æ¥i¥H§¹¾ã¨ú±o¦ý¦³ªÅÂ઺®É¶¡
ÁÂÁÂ
  1. Sub Ex_ºô­¶©³³¡()
  2.     Dim E As Object, R As Long, C As Long, i%
  3.     Dim timer As Date
  4.     'period1 = 1483286400     '2017/1/2
  5.     'period1 = 1451664000    '2016/1/2
  6.     'period1 = 915206400      '1999/1/2
  7.     'period2 = 1505174400     '2017/9/12

  8.     With CreateObject("InternetExplorer.Application")
  9.         .Visible = True
  10.         .Navigate "https://finance.yahoo.com/quote/AAPL/history?period1=915206400&period2=1505174400&interval=1d&filter=history&frequency=1d"
  11.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  12.         Set E = .document.ALL.TAGS("TR")
  13.        i = 0
  14.        timer = Time
  15.         Do
  16.             i = i + 1
  17.            With .document
  18. '¤èªk¤@¡G
  19. '                .Parentwindow.scrollBy 0, 500  '§ïÅÜ y ÂI¼Æ°µ¸ÕÅç
  20. '                With .DocumentElement
  21. '                    R = R + .clientheight
  22. '                    Debug.Print "±²°Ê¦¸¼Æ¡G" & i, "R:" & R, "SH: " & .scrollHeight ', "CH: " & .clientheight
  23. '                    If R - .clientheight > .scrollHeight Then Exit Do
  24. '                End With
  25. '==============================================================
  26. '¤èªk¤G¡G
  27.                   .Parentwindow.scrollBy 0, .DocumentElement.scrollHeight
  28.                   R = R + .DocumentElement.scrollHeight
  29.                   Debug.Print "±²°Ê¦¸¼Æ¡G" & i, "R:" & R, "SH: " & .DocumentElement.scrollHeight
  30.                   If R - .DocumentElement.scrollHeight > .DocumentElement.scrollHeight Then Exit Do
  31. ''''==============================================================
  32.                   
  33.             End With
  34.             DoEvents
  35.         Loop
  36.         
  37.         Debug.Print "®Éµ{¡G " & (Time - timer) * 86400
  38.         
  39.         ActiveSheet.Cells.Clear
  40.         For R = 1 To E.Length - 1
  41.             For C = 0 To E(R).Cells.Length - 1
  42.                 Cells(R, C + 1) = E(R).Cells(C).INNERTEXT
  43.             Next
  44.         Next
  45.         .Quit        'Ãö³¬ºô­¶
  46.     End With
  47.     MsgBox "Ok"
  48. End Sub
½Æ»s¥N½X

TOP

¦^´_ 3# Scott090

°Ñ¦Ò³o¸Ì  http://www.jb51.net/article/57614.htm
2# ªºµ{¦¡½X­×§ï¤F¬°
  1. With .document.documentElement
  2.                 ' Debug.Print .scrollTop , .clientHeighT, .scrollHeight  '***­pºâ¥X 37900¬°³Ì¤j­È
  3.                 If .scrollTop + .clientHeighT = .scrollHeight Then Exit Do
  4.             End With
½Æ»s¥N½X
¦ý´ú¸Õ®É,.°¸º¸ÁÙ¬O¤£¯à§¹¥þ¤U¸ü,¦³«Ý§V¤O
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# GBKEE


    GBKEE¤j¡G
ÁÂÁ¶i¤@¨Bªº¸Ñµª»P±Ð¾É ¤Î´£¨Ñªº°Ñ¦Òªººô§}
±NÄ~Äò¦aÁA¸Ñ»P¬ã¨s

·P®¦

TOP

¦^´_ 4# GBKEE

±q°Ñ¦Òªººô§}¤ºªº¦U­ÓÅܼơA  
scrollHeight,  scrolltop,  offsetheight, clientHeight, body.clientheight .....
¨S§ä¥X½T¹êªº ºu°Ê¼Æ¦r¬Û¤¬¤§¶¡ªºÃ­©wÃö«Y¡A³y¦¨ ¿Eµoºu°Ê°j°éªº¤£Ã­©w©Ê ¤Î ¨ú±oªº¸ê®Æ¤£¤@©w ¬O©³³¡³Ì«á¤@µ§¡F
¦Ó¡A±ý¨ú±oªº¸ê®Æ®æ¦¡¬O¥i¥H¬Jª¾¡A©Ò¥H§ï¥Î "¬O§_³Ì«á¤@µ§¸ê®Æ" ¨Ó¨M©wºu°Ê°j°é

§âµ{¦¡½X­×¹¢¦p¤U¡G
¼W¥[ ¤é´Á ÅÜ¼Æ Dim startDate as date,  A

startdate = #1999/1/2#

'¸õ¥X°j°é±ø¥ó If .scrolltop + .clientHeight = .scrollHeight Then exit do §ï¦¨
A = E(E.Length - 2).Cells(0).INNERTEXT
If CDate(Mid(A, 2, 3) & " " & Mid(A, 8, 2) & ", " & Right(A, 4)) - startDate < 5 Then Exit Do

´ú¸Õµ²ªG¬Oí©wªº

TOP

¦^´_ 6# Scott090
¤£¿ùªº³o¼Ë´N¥i¥H±o¨ì§¹¾ã¸ê®Æ.
µ{¦¡°õ¦æ®É¶¡¤j¬ù»Ý¤@¤ÀÄÁ,§Ú¾ã²z¤@¤U¦bª¬ºA¦C¤W¥[¤W¸ê°T.
  1. Option Explicit
  2. Dim Sh As Worksheet
  3. Dim xTimer As Date
  4. 'Dim Timer As Date   'Timer ¬°vbaªº¤º«Ø¨ç¼Æ ,ÅܼƦWºÙºÉ¶q¤£­n¬Û¦P
  5. Sub Ex_ºô­¶©³³¡()
  6.     Dim E As Object, Ie_Date As Date, i As Integer
  7.     Application.DisplayStatusBar = True
  8.     Application.StatusBar = False
  9.     Set Sh = ActiveSheet
  10.     Sh.Cells.Clear
  11.     On Error GoTo EE
  12.     With CreateObject("InternetExplorer.Application")
  13.         '.Visible = True
  14.         xTimer = Time
  15.         .Navigate "https://finance.yahoo.com/quote/AAPL/history?period1=915206400&period2=1505174400&interval=1d&filter=history&frequency=1d"
  16.         Do While .Busy Or .readyState <> 4: DoEvents: Application.StatusBar = "******  µ¥ ­Ô ºô ­¶ ¤U....¡¹¡¹¡¹" & GetTime:  Loop
  17.         Ie_Date = Getdate(.document.ALL.TAGS("INPUT")(4).Value)
  18.         Set E = .document.ALL.TAGS("tr")
  19.        Do
  20.             Application.StatusBar = "¡¹¡¹¡¹¡¹¡¹  ¸ê®Æ ¤U¸ü¤¤..." & GetTime & String(Val(GetTime), "¡¹")
  21.             .document.Parentwindow.scrollby 0, 37900
  22.            ' Do While .Busy Or .readyState <> 4: DoEvents:            Loop
  23.            If Getdate(E(E.Length - 2).Cells(0).innertext) - Ie_Date < 5 Then Exit Do
  24.             DoEvents
  25.         Loop
  26.         Set E = .document.ALL.TAGS("TABLE")(1)
  27.         
  28.         Ep .document.ALL.TAGS("TABLE")(1).outerHTML
  29.         Application.StatusBar = "** ¡¹" & xTimer & " - " & Time & "¡¹" & GetTime & " ,¤U¸ü ¦@ " & E.Rows.Length - 2 & " µ§¸ê®Æ §¹²¦ !! **"
  30.         .Quit        'Ãö³¬ºô­¶
  31.     End With
  32.     With Sh
  33.         For i = 2 To .Range("A1").End(xlDown).Row - 1
  34.             .Range("A" & i) = Getdate(.Range("A" & i))
  35.         Next
  36.         .Range("A:A").NumberFormatLocal = "yyyy/mm/dd"
  37.     End With
  38.    
  39. Exit Sub
  40. EE:  'µ{¦¡¹B¦æ³t«×¤j©óie®Éªº±¹¬I
  41.     Application.StatusBar = "ºô­¶¿ù»~µ¥­Ô¤¤....¡¹¡¹¡¹ " & GetTime
  42.     Application.Wait (Second(Now()) + 2)
  43.     Resume
  44. End Sub
  45. Private Sub Ep(S As String)
  46.     With CreateObject("InternetExplorer.Application")
  47.         .Navigate "about:Tabs"
  48.        ' .Visible = True
  49.         .document.body.innerHTML = S
  50.         .ExecWB 17, 2       '  Select All
  51.         .ExecWB 12, 2       '  Copy selection
  52.         With Sh
  53.             .Activate
  54.            ' .Cells.Clear
  55.             .Range("A1").Select
  56.             .PasteSpecial Format:="HTML", Link:=False, DisplayAsIcon:=False, NoHTMLFormatting:=True
  57.             .Range("A1").Select
  58.         End With
  59.         .Quit
  60.     End With
  61. End Sub
  62. Private Function Getdate(sDate As String) As Date
  63.     Dim A As String, b As Integer
  64.     A = Split(sDate, "-")(0)
  65.     b = AscW(Mid(A, 1, 1))
  66.     A = Replace(A, ChrW(b), " ")
  67.     A = Replace(A, "?", "")
  68.     Getdate = CDate(A)
  69. End Function
  70. Private Function GetTime() As String
  71.     GetTime = Application.Text(Time - xTimer, "   [S]¬í")
  72. End Function
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

§Ú¦b01¤å®Ñ³B²z°Ï¦³¬Ý¨ì¥u­n1.8¬íªºµ{¦¡½X

TOP

¦^´_ 7# GBKEE


    GBKEE ¤j¤j¡G
ÁÂÁ§AªºÁ`µ²

TOP

¦^´_ 8# quickfixer


   
§Ú¦b01¤å®Ñ³B²z°Ï¦³¬Ý¨ì¥u­n1.8¬íªºµ{¦¡½X


½Ð§âºô§}¶K¥X¨Ó¡AÅý¤j®a°Ñ¦Ò
ÁÂÁÂ

TOP

        ÀR«ä¦Û¦b : §ïÅܦۤv¬O¦Û±Ï¡A¼vÅT§O¤H¬O±Ï¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD