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

ªÑ»ù¥N¸¹©M°_©l¤é´Áªº§ì¨ú

¦^´_ 3# gelai01000001
CreateObject("InternetExplorer.application") ¦h·j´M¤@¤U·|¦h¤F¸Ñªº
  1. With CreateObject("InternetExplorer.application")
  2.     '¾ú¥v¦æ±¡ ¹w³]¬°¤@­Ó¤ë¸ê®Æ,¤é´Áªº§ó§ï»Ý¦bºô­¶¤W§ó§ï
  3.         .Navigate "http://www.cnyes.com/twstock/ps_historyprice/" & Code & ".htm"  'IEªººô§}
  4.         '.Visible = True
  5.         Application.StatusBar = Code & " ¾ú¥v¦æ±¡ µ¥­Ô¤¤..."
  6.         Do While .Busy Or .ReadyState <> 4     'µ¥­Ôºô­¶¸ê®Æ¤U¸ü§¹¦¨...
  7.              DoEvents
  8.         Loop
  9.         Set A = .Document.getelementsbytagname("input")  'ºô­¶¤¤¦¨­û tagname¬° "input"
  10.         A(5).Value = d_Start    '0 ¶}©lºâ°_²Ä6­Ó => 5     ¶}©l¤é´Á
  11.         A(6).Value = d_End      '0 ¶}©lºâ°_²Ä7­Ó => 6     µ²§ô¤é´Á
  12.         A(7).Click              '0 ¶}©lºâ°_²Ä8­Ó => 7     «ö¤U¬d¸ßÁä
  13.         T = Time
  14.         Do
  15.             DoEvents
  16.         Loop Until Time > T + #12:00:08 AM#              '«ö¤U¬d¸ßÁä«á,»Ýµ¥­Ôºô­¶¸ê®Æ¤U¸ü§¹¦¨
  17.         Set A = .Document.getelementsbytagname("table")(1) ''0 ¶}©lºâ°_²Ä2­Ó => 1
  18.         'ºô­¶¤¤¦¨­û tagname¬° "table" ,¬°¸ê®Æ©Ò¦bªº¦ì¸m.
  19.         Application.StatusBar = Code & " ¾ú¥v¦æ±¡ ¤U¸ü¤¤..."
  20.         Cells(2, 1) = .Document.getelementsbytagname("span")(79).innertext  'innertext: ¤å¦r
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 2# GBKEE

·PÁÂGBKEEª©¥Dªº¼ö¤ß¥Î¤ßªº¸Ñ´b¡C
¦]¦ì¥»¤H¤£§÷¡A¤£¬Æ¤F¸Ñ¤U¦Cµ{¦¡½Xªº»yªk¤Î°õ¦æ¥Î·N¡C
ÁٷнÐGBKEEª©¥D©âªÅ¥i»¡©úµù¸Ñ´b«ü¾É¤@¤U¶Ü¡H
  1. With CreateObject("InternetExplorer.application")
  2.         .Navigate "http://www.cnyes.com/twstock/ps_historyprice/" & Code & ".htm"
  3.         '.Visible = True
  4.         Application.StatusBar = Code & " ¾ú¥v¦æ±¡ µ¥­Ô¤¤..."
  5.         Do While .Busy Or .ReadyState <> 4
  6.              DoEvents
  7.         Loop
  8.         Set A = .Document.getelementsbytagname("input")
  9.         A(5).Value = d_Start
  10.         A(6).Value = d_End
  11.         A(7).Click
  12.         T = Time
  13.         Do
  14.             DoEvents
  15.         Loop Until Time > T + #12:00:08 AM#
  16.         Set A = .Document.getelementsbytagname("table")(1)
  17.         Application.StatusBar = Code & " ¾ú¥v¦æ±¡ ¤U¸ü¤¤..."
  18.         Cells(2, 1) = .Document.getelementsbytagname("span")(79).innertext
½Æ»s¥N½X
GBKEEª©¥D¡G°õ¦æµ{¦¡¹Lµ{¤¤¡Aµo²{¤U¸ü¦ÜEXCEL¤¤ªº¸ê®Æ¬O¦³¥Ñ¡qSh.Cells(i + 3, c + 1) = A.Rows(i).Cells(c).innertext¡r¦Ó¨Ó¡A
                        ¤£¦P©ó¤U¸üºô­¶¸ê®Æ¡qWebTables = "number"¡r¡A©Ò¥Îªº«ü¥O¤èªk¡C
§Ú¦³¤Wºô¦¬·j´M¬ÛÃö¸ê®Æ¡A¤j¬ù²M·¡ª¾¹D¡A¤W¦Cµ{¦¡½X¦¡¬O¦bVBAµ{¦¡¤¤±Ò°Êºô­¶ªº(javascript)«ü¥O¡C
¤£ª¾¬O»P¤£¬O©Î¤@ª¾¥b¸Ñ¡I·PÁÂGBKEEªº«ü¾É¡C

TOP

¦^´_ 1# gelai01000001
¤U¸ü3¦~¾ú¥vªÑ»ùªº¸ê®Æ
  1. Option Explicit
  2. Sub ¹d¦ëºô_¾ú¥v¦æ±¡()
  3.     Dim Sh As Worksheet, Code As String, d_Start As String, d_End  As String
  4.     Dim A As Object, i As Integer, c As Integer, T As Date
  5.     Code = InputBox("¿é¤JªÑ²¼¥N¸¹ :  ", "ªÑ²¼¥N¸¹", 2303)
  6.     d_End = InputBox("¿é¤Jµ²§ô¤é´Á :  ", "µ²§ô¤é´Á", Date)
  7.     If Len(Code) <= 3 Or Not IsDate(d_End) Then Exit Sub
  8.     Set Sh = ActiveSheet
  9.     With Sh
  10.         .UsedRange.Clear
  11.         .[a1] = Code
  12.         .[b1] = DateAdd("yyyy", -3, d_End)  '¤U¸ü3¦~¾ú¥vªÑ»ùªº¸ê®Æ
  13.         .[C1] = d_End
  14.         Code = .[a1]
  15.         d_Start = Format(.[b1], "yyyy/mm/dd")
  16.         d_End = Format(.[C1], "yyyy/mm/dd")
  17.     End With
  18.     With CreateObject("InternetExplorer.application")
  19.         .Navigate "http://www.cnyes.com/twstock/ps_historyprice/" & Code & ".htm"
  20.         '.Visible = True
  21.         Application.StatusBar = Code & " ¾ú¥v¦æ±¡ µ¥­Ô¤¤..."
  22.         Do While .Busy Or .ReadyState <> 4
  23.              DoEvents
  24.         Loop
  25.         Set A = .Document.getelementsbytagname("input")
  26.         A(5).Value = d_Start
  27.         A(6).Value = d_End
  28.         A(7).Click
  29.         T = Time
  30.         Do
  31.             DoEvents
  32.         Loop Until Time > T + #12:00:08 AM#
  33.         Set A = .Document.getelementsbytagname("table")(1)
  34.         Application.StatusBar = Code & " ¾ú¥v¦æ±¡ ¤U¸ü¤¤..."
  35.         Cells(2, 1) = .Document.getelementsbytagname("span")(79).innertext
  36.         For i = 0 To A.Rows.Length - 1
  37.             For c = 0 To A.Rows(i).Cells.Length - 1
  38.                 Sh.Cells(i + 3, c + 1) = A.Rows(i).Cells(c).innertext
  39.             Next
  40.         Next
  41.        .Quit
  42.     End With
  43.     Application.StatusBar = Code & " ¾ú¥v¦æ±¡ " & Application.Text(Time - T, "[S] ¬í") & " ¤U¸ü§¹¦¨"
  44.     MsgBox "OK"
  45.     Application.StatusBar = False
  46. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

«ü©w¤U¸ü3¦~¾ú¥vªÑ»ùªº¸ê®Æ

³Â·Ð½Ð¦U¦ì°ª¤â±M®a¤Îª©¥D«ü¾É¸Ñ´b¡G
¤U­±ºô§}¤¤¥i«ü©w¬d¸ß¾ú¥v¸ê®Æªº°Ï¶¡¿ï¶µ(¹w³]­È¬°20¤Ñ)¡A¦³¥ý¦bºô¯¸¤¤§ó§ï¬d¸ß°Ï¶¡¬°3¦~¡C
¦ý¨C¦¸¤U¸ü¶×¤JEXCELªº¸ê®Æ¥u¦³21¤Ñ¡A¤£ª¾»Ý­n¥[¤J¤°»òµ{¦¡½X¤~¥i¸Ñ¨M¡H¡H
www.cnyes.com/twstock/ps_historyprice/6282.htm
  1. Sub Macro1()

  2.     With ActiveSheet.QueryTables.Add(Connection:= _
  3.         "URL;http://www.cnyes.com/twstock/ps_historyprice/6282.htm", Destination:= _
  4.         Range("A1"))
  5.         .RefreshStyle = xlOverwriteCells
  6.         .WebTables = "2"
  7.         .Refresh BackgroundQuery:=False
  8.     End With
  9.     ActiveWindow.SmallScroll Down:=-21

  10. End Sub
½Æ»s¥N½X
¦]¬°YAHOO¡BGOOGLEªº¾ú¥v¸ê®Æ¦³®ÉµLªkÅã¥Ü¨Ò¥~(¶}¥ð¥«)ªº¼Æ¾Ú¡A³y¦¨­pºâMA­Èªº¼Æ¾Ú¤£·Ç½T¡C
·PÁ¦U¦ì°ª¤â±M®a¼·ªÅ¸Ñ´b¡C

TOP

        ÀR«ä¦Û¦b : ¤H¥Í¤£¤@©w²y²y¬O¦n²y¡A¦ý¬O¦³¾ú½mªº±j¥´ªÌ¡AÀH®É³£¥i¥H´§´Î¡C
ªð¦^¦Cªí ¤W¤@¥DÃD