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

¤j½L¾ú¥v¸ê®Æ¬d¸ß

¥»©«³Ì«á¥Ñ GBKEE ©ó 2016-1-11 14:06 ½s¿è

¦^´_ 2# kim223824
  1. Option Explicit
  2. Sub Ex_TABLE() '¬d¬Ý¤j½L¾ú¥v¸ê®Æ¬d¸ß,¸ê®Æ©Ò¦bªºTABLE
  3.     Dim i As Integer, E As Object, url, xTable, A
  4.     url = "http://www.twse.com.tw/ch/trading/indices/MI_5MINS_HIST/MI_5MINS_HIST.php"
  5.     With CreateObject("InternetExplorer.application")
  6.         .Visible = True
  7.         .Navigate url
  8.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  9.         With .Document
  10.             .ALL("myear").Value = "104"
  11.             .ALL("mmon").Value = "12"
  12.             For Each E In .ALL.tags("input")
  13.                 If E.Type = "button" And E.Value = "¬d¸ß" Then
  14.                     E.Click
  15.                     Exit For
  16.                 End If
  17.             Next
  18.         End With
  19.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  20.         Set xTable = .Document.getElementsByTagName("TABLE")
  21.         On Error Resume Next
  22.             For Each E In xTable
  23.                     i = i + 1
  24.                     Cells(i, 1) = A   '¬d¬Ý¸ê®Æ¦b¨º¤@­ÓTABLE
  25.                     A = A + 1
  26.                     i = i + 1
  27.                    Cells(i, "A") = E.innertext
  28.             Next
  29.         .Quit        'Ãö³¬ºô­¶
  30.     End With
  31. End Sub
½Æ»s¥N½X
  1. Option Explicit
  2. Sub ¤j½L«ü¼Æ20160110()
  3.     Dim xTable As Object, k As Integer, c As Integer, r As Integer
  4.     Dim url As String, i As Integer, E As Object
  5.     'Sheets("¤U¸ü").Select
  6.     url = "http://www.twse.com.tw/ch/trading/indices/MI_5MINS_HIST/MI_5MINS_HIST.php"
  7.         With CreateObject("InternetExplorer.application")
  8.         .Visible = True
  9.         .Navigate url
  10.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  11.                  With .Document
  12.                     .ALL("myear").Value = "104"
  13.                     .ALL("mmon").Value = "12"
  14.                    ' .all("onclick").Click                    '«ö¤U«öÁ䪺
  15.                     For Each E In .ALL.tags("input")
  16.                         If E.Type = "button" And E.Value = "¬d¸ß" Then
  17.                             E.Click        '«ö¤U¬d¸ßÁä
  18.                             Exit For
  19.                         End If
  20.                     Next
  21.                 End With
  22.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  23.         'Sub Ex_TABLE() ¬d¬Ý¤j½L¾ú¥v¸ê®Æ¬d¸ß,±oª¾¸ê®Æ©Ò¦bªºTABLE
  24.         Set xTable = .Document.getElementsByTagName("TABLE")(10) '¸ê®Æ¦b³o
  25.         With Sheets("¤U¸ü")
  26.             .UsedRange.Clear
  27.             k = k + 1
  28.             For r = 0 To xTable.Rows.Length - 1
  29.                 For c = 0 To xTable.Rows(r).Cells.Length - 1
  30.                     .Cells(k, c + 1) = xTable.Rows(r).Cells(c).innertext
  31.                 Next
  32.                 k = k + 1
  33.             Next
  34.         End With
  35.         .Quit
  36.     End With
  37. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 4# kim223824
  1. Option Explicit
  2. Sub Ex_Table() '¬d¬Ý¤j½L¾ú¥v¸ê®Æ¬d¸ß,¸ê®Æ©Ò¦bªºTABLE
  3.     Dim i As Integer, E As Object, URL, xTable As Object
  4.     Dim xR As Integer, xT As Integer, R As Object, C As Object
  5.     URL = "http://www.twse.com.tw/ch/trading/indices/MI_5MINS_HIST/MI_5MINS_HIST.php"
  6.     With CreateObject("InternetExplorer.application")
  7.         .Visible = True
  8.         .Navigate URL
  9.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  10.         With .document
  11.             .ALL("myear").Value = "104"
  12.             .ALL("mmon").Value = "12"
  13.             For Each E In .ALL.tags("input")
  14.                 If E.Type = "button" And E.Value = "¬d¸ß" Then
  15.                     E.Click
  16.                     Exit For
  17.                 End If
  18.             Next
  19.         End With
  20.         Do While .Busy Or .readyState <> 4: DoEvents: Loop
  21.         Set xTable = .document.getElementsByTagName("TABLE")
  22.         ActiveSheet.UsedRange.Clear
  23.         xR = 1                              '¤u§@ªí¦C¸¹
  24.         For xT = 0 To xTable.Length - 1
  25.             Cells(xR, 1) = "²Ä" & xT & "Table"
  26.             For Each R In xTable(xT).Rows   'TableªºRowsª«¥ó¶°¦X
  27.                 xR = xR + 1                 '¤U¤@¦C¸¹
  28.                 i = 1
  29.                 For Each C In R.Cells       'TableªºRowª«¥óªºCellsª«¥ó¶°¦X
  30.                     Cells(xR, i) = C.innertext
  31.                     i = i + 1
  32.                 Next
  33.             Next
  34.             xR = xR + 1                      '¤U¤@¦C¸¹
  35.         Next
  36.         .Quit        'Ãö³¬ºô­¶
  37.     End With
  38. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¡i®É¶¡¦pÆp¥Û¡j®É¶¡¹ï¤@­Ó¦³´¼¼zªº¤H¦Ó¨¥¡A´N¦pÆp¥Û¯ë¬Ã¶Q¡F¦ý¹ï·M¤H¨Ó»¡¡A«o¹³¬O¤@§âªd¤g¡A¤@ÂI»ù­È¤]¨S¦³¡C
ªð¦^¦Cªí ¤W¤@¥DÃD