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

[µo°Ý] ºô¸ôCSV¤U¸ü°ÝÃD

RE: ºô¸ôCSV¤U¸ü°ÝÃD

¦^´_ 1# spermbank
³o­ì©lÀɮפ¤§ä¤£¨ìCSVÀɮתººô§}¥i¤U¸ü!!
¸Õ¸Õ¬Ý (¥i¸ÕµÛ­×§ï¤U¸ü¤W¥«,¤WÂdªº¸ê®Æ)
  1. Option Explicit
  2. Sub ¤½¶}¸ê°TÆ[´ú¯¸()
  3.     Dim Ie As Object, xx, k, j, i, AA As Variant
  4.     Dim T As Date
  5.     ActiveSheet.Cells.Clear
  6.      Application.DisplayStatusBar = True
  7.     On Error GoTo ie_err
  8.     Set Ie = CreateObject("InternetExplorer.Application")
  9.     Ie.Navigate "http://mops.twse.com.tw/mops/web/t51sb08"
  10.     Ie.Visible = True
  11.     Do While Ie.Busy Or Ie.ReadyState <> 4: DoEvents: Loop
  12.     '**********  ­×§ï³o¸Ì ªº¿ï¶µ
  13.     Ie.Document.ALL(632).Value = "sii"   '¤W¥« = sii,¤WÂd = otc,¿³Âd = rotc,¤½¶}µo¦æ = pub
  14.     Ie.Document.ALL(643).Value = "101"   '¦~«×
  15.     Ie.Document.ALL(650).Value = "04"    '²Ä¤@©u = 01,²Ä¤G©u = 02,²Ä¤T©u = 03,²Ä¥|©u = 04
  16.     Ie.Document.ALL(667).Click
  17.    
  18.     Ie.Visible = False
  19.     ºô­¶¾ã²z
  20.     Set AA = Ie.Document.getelementsbytagname("table")   '¸ê®Æ°Ï
  21.    ' Ie.Quit
  22.     T = Time
  23.     Application.ScreenUpdating = False
  24.     With ActiveSheet
  25.         On Error Resume Next
  26.         For xx = 13 To AA.Length - 1
  27.             For i = 0 To AA(xx).Rows.Length - 1      '¼g¤J¸ê®Æ
  28.                 k = k + 1
  29.                 For j = 0 To 19
  30.                     .Cells(k, 1).Select
  31.                     Application.StatusBar = "¤U¸ü¸ê®Æ¤¤ ..." & k - 1
  32.                     .Cells(k, j + 1) = AA(xx).Rows(i).Cells(j).innertext
  33.                 Next
  34.             Next
  35.         Next
  36.         Set AA = .Range("S2:S" & .[S2].End(xlDown).Row)
  37.         AA.Replace "°ò¥»¨CªÑ¬Õ¾l", "", xlWhole
  38.         AA.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
  39.         .Cells(.Rows.Count, 1).End(xlUp).EntireRow.Delete
  40.          ActiveWindow.ScrollRow = .Cells(.Rows.Count, 1).End(xlUp).Row - 20
  41.         .Cells(.Rows.Count, 1).End(xlUp).Select
  42.     End With
  43.     Application.ScreenUpdating = True
  44.     'Ie.Quit
  45.     Application.StatusBar = "¤U¸ü¸ê®Æ®É¶¡ : " & Format(Time - T, ["S¬í"])
  46.     End
  47. ie_err:
  48.     MsgBox "ºô­¶¦³°ÝÃD,½Ð­«·s°õ¦æ..."
  49.     Set Ie = Nothing
  50. End Sub
  51. Private Sub ºô­¶¾ã²z()   'µ¥«Ýºô­¶¤U¸ü¸ê®Æ§¹²¦ªº®É¶¡
  52.     Dim Tt(1 To 3) As Date
  53.     Tt(1) = Time
  54.     Tt(2) = Time
  55.     Tt(3) = #12:00:10 AM#     '10¬í ½Õ¾ã³o¸Ì
  56.     Do
  57.         If Time > Tt(2) Then
  58.             Application.StatusBar = "ºô­¶¤U¸ü¤¤ ³Ñ¾l¬í¼Æ.. " & Second(Tt(1) + Tt(3) - Time)
  59.             Tt(2) = Time
  60.         End If
  61.         DoEvents
  62.     Loop Until Time > Tt(1) + Tt(3)
  63.     Application.StatusBar = "¸ê®Æ¤U¸ü¤¤...."
  64. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2013-3-30 16:06 ½s¿è

¦^´_ 3# spermbank
  1. ³oºô­¶¦³­×§ï±±¨î¶µ,2# ³o¨Çµ{¦¡½X¤£¾A¥Î, 4#ªºµ{¦¡½X¤w­×§ï¬°¥¿½T
  2. Ie.Document.ALL(632).Value = "sii"   '¤W¥« = sii,¤WÂd = otc,¿³Âd = rotc,¤½¶}µo¦æ = pub
  3. Ie.Document.ALL(643).Value = "101"   '¦~«×
  4. Ie.Document.ALL(650).Value = "04"    '²Ä¤@©u = 01,²Ä¤G©u = 02,²Ä¤T©u = 03,²Ä¥|©u = 04
  5. Ie.Document.ALL(667).Click
½Æ»s¥N½X
¨C¤@ºô­¶ªºªí³æ«Ø¸m¤£¤@¼Ë,»Ý¤@¤@¥h´M§ä
  1. Option Explicit
  2. Sub ¤½¶}¸ê°TÆ[´ú¯¸()
  3.     Dim ie As Object, xx, k, j, i, AA As Variant
  4.     Dim T As Date, ¸ê°T As String
  5.     Do
  6.         ¸ê°T = InputBox("1: ·l¯qªí" & vbLf & "2: ¦X¨Ö·l¯qªí")   '¿ï¾Ü¤½¶}¸ê°TÆ[´ú¯¸ªºªí®æ
  7.        '¸ê°T = InputBox("1: ·l¯qªí" & vbLf & "2: ¦X¨Ö·l¯qªí"& vbLf & "3: ???ªí"...............)
  8.         If ¸ê°T = "" Then Exit Sub                              '¤£¿ï¾Üµ²§ôµ{¦¡
  9.     Loop Until Val(¸ê°T) > 0 And Val(¸ê°T) <= 2 '                Val(¸ê°T)<=???  µ²§ô¿ï¾Üªí³æ
  10.     ActiveSheet.Cells.Clear
  11.     Application.DisplayStatusBar = True
  12.     Application.StatusBar = "....... ºô­¶¶}±Ò¤¤.......... "
  13.    
  14.   '  On Error GoTo ie_err
  15.     Set ie = CreateObject("InternetExplorer.Application")
  16.     ie.Navigate ¤U¸üºô§}(¸ê°T)
  17.     Do While ie.Busy Or ie.ReadyState <> 4
  18.             DoEvents
  19.     Loop
  20.     With ie.Document
  21.         T = Time
  22.         Do While ie.Busy Or ie.ReadyState <> 4
  23.             If Time = T + #12:01:00 AM# Then GoTo ie_err                'µ¥­Ôºô­¶²§±`:µ²§ôµ{¦¡
  24.             DoEvents
  25.         Loop
  26.         '**********  ­×§ï³o¸Ì ªº¿ï¶µ
  27.         .getelementbyID("TYPEK").Value = "sii"  '¤W¥« = sii,¤WÂd = otc,¿³Âd = rotc,¤½¶}µo¦æ = pub
  28.         .getelementbyID("year").Value = "101"    '¦~«×
  29.         .getelementbyID("season").Value = "02"    '²Ä¤@©u = 01,²Ä¤G©u = 02,²Ä¤T©u = 03,²Ä¥|©u = 04
  30.         For i = 0 To .getelementsbytagname("input").Length - 1
  31.             If .getelementsbytagname("input")(i).Type = "button" And .getelementsbytagname("input")(i).Value = " ·j´M " Then
  32.                 .getelementsbytagname("input")(i).Click
  33.             End If
  34.         Next
  35.         µ¥«Ýºô­¶
  36.         Set AA = .getelementsbytagname("table")   '¸ê®Æ°Ï
  37.     End With
  38.     T = Time
  39.     With ActiveSheet
  40.         .Cells(1, "A") = IIf(¸ê°T = 1, "·l¯qªí", "¦X¨Ö·l¯qªí")
  41.         .Cells(1, "B") = ¥«³õ§O(ie.Document.getelementbyID("TYPEK").Value)
  42.         .Cells(1, "C") = ie.Document.getelementbyID("year").Value & "¦~«×"
  43.         .Cells(1, "D") = ie.Document.getelementbyID("season").Value & "©u"
  44.         .Cells(1).Select
  45.         Application.ScreenUpdating = False
  46.         k = 1
  47.         On Error Resume Next
  48.         For xx = ºô­¶ªí®æ(¸ê°T) To AA.Length - 1
  49.             For i = 0 To AA(xx).Rows.Length - 1      '¼g¤J¸ê®Æ
  50.                 k = k + 1
  51.                 For j = 0 To 19
  52.                     Application.StatusBar = "¤U¸ü¸ê®Æ¤¤ ..." & k - 1
  53.                     .Cells(k, j + 1) = AA(xx).Rows(i).Cells(j).innertext
  54.                 Next
  55.             Next
  56.         Next
  57.         Set AA = .Range("S3:S" & .[S3].End(xlDown).Row)
  58.         AA.Replace "°ò¥»¨CªÑ¬Õ¾l", "", xlWhole
  59.         AA.SpecialCells(xlCellTypeBlanks).EntireRow.Delete
  60.         .Cells(.Rows.Count, 1).End(xlUp).EntireRow.Delete
  61.         .Cells.EntireColumn.AutoFit
  62.         .[A1].Select
  63.     End With
  64.     Application.ScreenUpdating = True
  65.     ie.Quit
  66.     Application.StatusBar = "¤U¸ü¸ê®Æ®É¶¡ : " & Format(Time - T, ["S¬í"])
  67.     End
  68. ie_err:
  69.     ie.Quit
  70.     MsgBox "ºô­¶¦³°ÝÃD,½Ð­«·s°õ¦æ..."
  71.     End
  72. ¸ê°T_Err:
  73. End Sub
  74. Private Sub µ¥«Ýºô­¶()    'µ¥«Ýºô­¶¤U¸ü¸ê®Æ§¹²¦ªº®É¶¡
  75.     Dim Tt(1 To 3) As Date
  76.     Tt(1) = Time
  77.     Tt(2) = Time
  78.     Tt(3) = #12:00:10 AM#     '10¬í ½Õ¾ã³o¸Ì
  79.     Do
  80.         If Time > Tt(2) Then
  81.             Application.StatusBar = "ºô­¶¤U¸ü¤¤ ³Ñ¾l¬í¼Æ.. " & Second(Tt(1) + Tt(3) - Time)
  82.             Tt(2) = Time
  83.         End If
  84.         DoEvents
  85.     Loop Until Time > Tt(1) + Tt(3)
  86.     Application.StatusBar = "¸ê®Æ¤U¸ü¤¤...."
  87. End Sub
  88. Private Function ¤U¸üºô§}(xWord As String) As String      '¶Ç¦^¿ï¾Üªººô§}
  89.     Select Case xWord
  90.         Case "1"
  91.             ¤U¸üºô§} = "http://mops.twse.com.tw/mops/web/t51sb08" '·l¯qªí
  92.         Case "2"
  93.             ¤U¸üºô§} = "http://mops.twse.com.tw/mops/web/t51sb13" '¦X¨Ö·l¯qªí
  94.         ''Case "3"     ·sºô­¶ªººô§}
  95.         ''
  96.         ''
  97.     End Select
  98. End Function
  99. Private Function ¥«³õ§O(xWord As String) As String
  100.        '¤W¥« = sii,¤WÂd = otc,¿³Âd = rotc,¤½¶}µo¦æ = pub
  101.     Select Case xWord
  102.         Case "sii"
  103.             ¥«³õ§O = "¤W¥«"
  104.         Case "otc"
  105.             ¥«³õ§O = "¤WÂd"
  106.         Case "rotc"
  107.             ¥«³õ§O = "¿³Âd"
  108.         Case "pub"
  109.             ¥«³õ§O = "¤½¶}µo¦æ"
  110.     End Select
  111. End Function
  112. Private Function ºô­¶ªí®æ(xWord As String) As Integer
  113.     Select Case xWord
  114.         Case "1"
  115.             ºô­¶ªí®æ = 13  '·l¯qªí
  116.         Case "2"
  117.             ºô­¶ªí®æ = 12  '¦X¨Ö·l¯qªí
  118.         
  119.         ''¨C¤@ºô­¶ªºªí³æ«Ø¸m¤£¤@¼Ë,»Ý¤@¤@¥h´M§ä
  120.         '' ¦Û¦æ¬d¬Ý·s¼W Case "3"......
  121.         ''
  122.     End Select
  123. End Function
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¥»©«³Ì«á¥Ñ GBKEE ©ó 2013-3-31 18:38 ½s¿è

¦^´_ 13# HSIEN6001
§R±¼ encodeURIComponent=1

¦^´_ 14# HSIEN6001
¦³ diabo  ´£¨Ñªººô§}¦n¿ì¨Ç
  1. Option Explicit
  2. Sub Ex()
  3. Dim ie As Object, aa As Object, k As Integer, xx As Integer, i As Integer, j As Integer
  4. ActiveSheet.Cells.Clear
  5. Set ie = CreateObject("InternetExplorer.Application")
  6.     ie.Navigate "http://mops.twse.com.tw/mops/web/ajax_t51sb13?step=1&firstin=1&off=1&TYPEK=sii&year=100&season=04"
  7.      Do While ie.Busy Or ie.ReadyState <> 4:   DoEvents:     Loop
  8.     On Error Resume Next
  9.     Set aa = ie.Document.getelementsbytagname("table")   'ªí®æ¸ê®Æ°Ï
  10.      k = 1
  11.     On Error Resume Next
  12.         For xx = 0 To aa.Length - 1
  13.         '§ä¨ì«á­×§ï For xx = ??? To aa.Length - 1
  14.             For i = 0 To aa(xx).Rows.Length - 1      '¼g¤J¸ê®Æ
  15.                 Cells(k, 1) = "Table" & xx
  16.                 k = k + 1                            '¦C¼Æ
  17.                 For j = 0 To 19
  18.                     Application.StatusBar = "¤U¸ü¸ê®Æ¤¤ ..." & k - 1
  19.                     Cells(k, j + 2) = aa(xx).Rows(i).Cells(j).innertext
  20.                 Next
  21.             Next
  22.         Next
  23.     ie.Quit
  24. End Sub
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

¦^´_ 16# HSIEN6001
¥u¬O¨Sªk²z¸Ñ----->ºô­¶ªí®æ 13 or 12  ¹J¨ì¤£¦Pºô­¶¡A§P§O¤è¦¡¡H¡I

4# ³o¬qµ{¦¡½X
  1.       k = 1
  2. 47.        On Error Resume Next
  3. 48.        For xx = ºô­¶ªí®æ(¸ê°T) To AA.Length - 1
  4. 49.            For i = 0 To AA(xx).Rows.Length - 1      '¼g¤J¸ê®Æ
  5. 50.                k = k + 1
  6. 51.                For j = 0 To 19
  7. 52.                    Application.StatusBar = "¤U¸ü¸ê®Æ¤¤ ..." & k - 1
  8. 53.                    .Cells(k, j + 1) = AA(xx).Rows(i).Cells(j).innertext
  9. 54.                Next
  10. 55.            Next
  11. 56.        Next
½Æ»s¥N½X
§ï¦¨15#³o¬qµ{¦¡½X
  1. 10.     k = 1
  2. 11.    On Error Resume Next
  3. 12.        For xx = 0 To aa.Length - 1  
  4. 13.       '¤£¦Pºô­¶¡A§P§O¤è¦¡ '§ä¨ì«á­×§ï For xx = ??? To aa.Length - 1        
  5. 14.            For i = 0 To aa(xx).Rows.Length - 1      '¼g¤J¸ê®Æ
  6. 15.                Cells(k, 1) = "Table" & xx
  7. 16.                k = k + 1                            '¦C¼Æ
  8. 17.                For j = 0 To 19
  9. 18.                    Application.StatusBar = "¤U¸ü¸ê®Æ¤¤ ..." & k - 1
  10. 19.                    Cells(k, j + 2) = aa(xx).Rows(i).Cells(j).innertext
  11. 20.                Next
  12. 21.            Next
  13. 22.        Next
½Æ»s¥N½X
·P®¦ªº¤ß......(¦b³Â»¶®a±Ú°Q½×°Ï.¥Î¤ß¾Ç²ß·|¦³¶i¨Bªº)
¦ý¸ê·½µL­­,«á´©¦³­­,  ¤@¤Ñ1¤¸ªºÃÙ§U,¤H¤H¦³¯à¤O.

TOP

        ÀR«ä¦Û¦b : ¡i®É¶¡¦¨´N¤@¤Á¡j®É¶¡¥i¥H³y´N¤H®æ¡A¥i¥H¦¨´N¨Æ·~¡A¤]¥i¥HÀx¿n¥\¼w¡C
ªð¦^¦Cªí ¤W¤@¥DÃD