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

[µo°Ý] ¤W¥«­ÓªÑ¤é¦¨¥æ¸ê°T¤U¸ü§ïª©«Øij

[µo°Ý] ¤W¥«­ÓªÑ¤é¦¨¥æ¸ê°T¤U¸ü§ïª©«Øij

­ì¥ý°Ñ¦Ò¯¸¤W¸ê®Æ¨Ï¥Îmsxml2.xmlhttp¼g¤F¤U¸ü¤W¥«ªÑ²¼¤é¦¨¥æ¸ê°Tªº¥¨¶°¡A¨S·Q¨ì¤~¥Î¨â¤Ñ¡A¤µ¤Ñ¬ðµM¤£¯à¨Ï¥Î¤F¡A­ì¨ÓTWSE¤S§ïª©¤F¡A¬d¤F¥b¤Ñmsxml2.xmlhttp¦n¹³¨S¿ìªk§ì°ÊºA²£¥Íªºªí®æ¸ê®Æ¡A·Q­×§ï¥¨¶°¡A«o¤£ª¾¸Ó¥Î¤°»ò¤è¦¡¡A¤£ª¾¬O§_¦³«Øijªº¤u¨ã¡H
ªþ¤W­ì¥ýªº¥¨¶°¨Ñ°Ñ ¤W¥«µý¨÷¤é¦¨¥æ.rar (59.21 KB) ¦Ò

¦^´_ 35# t8899

©xºôªº°ÝÃD¡A¹L¤@°}¤l´N¥¿±`

TOP

¦^´_  t8899

³£¥i¥H¦Û¤v¸ü¤Jexcel

¦Û¤w¿ý»s¤@¤U±Æ§ÇÀ³¸Ó«Ü²³æ

½m²ß¬Ý¬Ý
joey0415 µoªí©ó 2017-6-22 18:37


½Ð±Ð³s±µ®Éµ¥4¬í¦pªG¨S¦^À³´N¸õ¥X¡A­n¦p¦ó§ï??
  Application.ScreenUpdating = False
    Sheets("Sheet5").Select
Cells.ClearContents
ddd = "URL;http://www.twse.com.tw/exchangeReport/TWT48U?response=html"
With ActiveSheet.QueryTables.Add(Connection:=ddd, Destination:=Range("$A$1"))
.WebTables = "1"
.Refresh BackgroundQuery:=False
End With

TOP

¦^´_ 33# t8899

³£¥i¥H¦Û¤v¸ü¤Jexcel

¦Û¤w¿ý»s¤@¤U±Æ§ÇÀ³¸Ó«Ü²³æ

½m²ß¬Ý¬Ý

TOP

¦^´_  t8899
joey0415 µoªí©ó 2017-6-22 18:29

¥i¥H«ö·Ó¤é´Á¥Ñ¤p¨ì¤j±Æ§Ç¶Ü?

TOP

TOP

¦^´_  t8899
¦Û¤v½m²ß¬Ý¬Ý
joey0415 µoªí©ó 2017-6-3 20:50


¦A½Ð±Ð¤@¤U­±³o­Ó
http://www.twse.com.tw/zh/page/trading/exchange/TWT48U.html
  («ö·Ó°£Åv°£®§¤é´Á¥Ñ¤p¨ì¤j±Æ§Ç)

TOP

¦^´_ 29# jsleee
°²³]­n§ìhttp://www.twse.com.tw/exchangeReport/MI_INDEX?response=html&date=20170609&type=MS
³oºô­¶ªº²Ä¤@­Óªí¡A±q²Ä¤G¦C¶}©l§ì
(¦]µ{¦¡§PÂ_Äæ¦ì¯x°}«Å§i¾a­n§ì¨úªº²Ä¤@¦C¦³´X­ÓÄæ¦ì, ­Y­n±q²Ä¤@¦C¶}©l§ì, §A¦Û¤v­n¦A§ï¤@¤U)
¼g¤@¬qµ{¦¡µ¹function»Ý­nªº¸ê°T¡A¦A§âfunction¶Ç¦^ªº¸ê®Æ¡A¿é¥X¨ìexcel¬¡­¶ªí¡A°Ñ¦Ò¦p¤U
  1. Sub main()
  2. Dim URL$, VV As Boolean, AB() As String

  3. URL = "http://www.twse.com.tw/exchangeReport/MI_INDEX?response=html&date=20170609&type=MS"
  4. AB = GetWebTb1(URL, 1, 2, 1, VV)
  5. If VV = True Then ActiveSheet.Range("A1:E63") = AB

  6. End Sub

  7. Private Function GetWebTb1(sURL00$, nTT00%, nRR00%, nCC00%, bRd00 As Boolean)
  8. '===sURL00      ¬°Â^¨úºô§}
  9. '===nTT00       ¬°Åª¨ú²Ä´X­ÓTable(±q1¶}©l)
  10. '===nRR00       ¸ÓTable¥Ñ²Ä´X¦C¶}©lŪ¨ú(±q1¶}©l)
  11. '===nCC00       ¸ÓTable¥Ñ²Ä´XÄæ¶}©lŪ¨ú(±q1¶}©l)
  12. '===bRd00       ¸Ó¸ê®Æ¬O§_¿é¥X
  13. Dim nR00%, nC00%, sTemp() As String, oXml As Object, oDoc As Object, oE As Object, tt As Date
  14.     Set oXml = CreateObject("MSXML2.XMLHTTP.6.0")
  15.     Set oDoc = CreateObject("HTMLFile")
  16.     bRd00 = True
  17. rSend:
  18.     tt = Now() + TimeValue("0:00:20")
  19.     With oXml
  20.         .Open "Get", sURL00, True
  21.         .setRequestHeader "Content-type", "application/x-www-form-urlencoded"
  22.         .send
  23.         On Error Resume Next
  24.         Do While .ReadyState <> 4 Or .Status <> 200
  25.             DoEvents
  26.             If Now > tt Then GoTo rSend
  27.         Loop
  28.         On Error GoTo 0
  29.         oDoc.write .responseText
  30.     End With
  31.     If oDoc.all.tags("Table")(nTT00 - 1) Is Nothing Then bRd00 = False: GoTo Err1
  32.     Set oE = oDoc.all.tags("Table")(nTT00 - 1)
  33.     With oE
  34.         ReDim sTemp(.Rows.Length - nRR00, .Rows(nRR00 - 1).Cells.Length - nCC00)
  35.         For nR00 = 0 To .Rows.Length - nRR00
  36.             For nC00 = 0 To .Rows(nR00 + nRR00 - 1).Cells.Length - nCC00
  37.                 sTemp(nR00, nC00) = .Rows(nR00 + nRR00 - 1).Cells(nC00 + nCC00 - 1).innerText
  38.             Next nC00
  39.         Next nR00
  40.     End With
  41. Err1:
  42.     GetWebTb1 = sTemp
  43.     oXml.abort
  44.     oDoc.Close
  45.     Set oXml = Nothing
  46.     Set oDoc = Nothing
  47.     Set oE = Nothing
  48. End Function
½Æ»s¥N½X

TOP

¦^´_ 28# prin.huang


    ¤£¦n·N«ä
    ½Ð°Ý prin.huang ¥ý¶i
    ³o­ÓFunction ­n¦p¦ó¹B¥Î¡H

TOP

¦^´_ 27# jsleee
¦Û¤v¼gªºfunctionµ¹§A°Ñ¦Ò¡A·|¦^¶Ç¤@­Óstring°}¦C
  1. Private Function GetWebTb1(sURL00$, nTT00%, nRR00%, nCC00%, bRd00 As Boolean)
  2. '===sURL00      ¬°Â^¨úºô§}
  3. '===nTT00       ¬°Åª¨ú²Ä´X­ÓTable(±q1¶}©l)
  4. '===nRR00       ¸ÓTable¥Ñ²Ä´X¦C¶}©lŪ¨ú(±q1¶}©l)
  5. '===nCC00       ¸ÓTable¥Ñ²Ä´XÄæ¶}©lŪ¨ú(±q1¶}©l)
  6. '===bRd00       ¸Ó¸ê®Æ¬O§_¿é¥X
  7. Dim nR00%, nC00%, sTemp() As String, oXml As Object, oDoc As Object, oE As Object, tt As Date
  8.     Set oXml = CreateObject("MSXML2.XMLHTTP.6.0")
  9.     Set oDoc = CreateObject("HTMLFile")
  10.     bRd00 = True
  11. rSend:
  12.     tt = Now() + TimeValue("0:00:20")
  13.     With oXml
  14.         .Open "Get", sURL00, True
  15.         .setRequestHeader "Content-type", "application/x-www-form-urlencoded"
  16.         .send
  17.         On Error Resume Next
  18.         Do While .ReadyState <> 4 Or .Status <> 200
  19.             DoEvents
  20.             If Now > tt Then GoTo rSend
  21.         Loop
  22.         On Error GoTo 0
  23.         oDoc.write .responseText
  24.     End With
  25.     If oDoc.all.tags("Table")(nTT00 - 1) Is Nothing Then bRd00 = False: GoTo Err1
  26.     Set oE = oDoc.all.tags("Table")(nTT00 - 1)
  27.     With oE
  28.         ReDim sTemp(.Rows.Length - nRR00, .Rows(nRR00 - 1).Cells.Length - nCC00)
  29.         For nR00 = 0 To .Rows.Length - nRR00
  30.             For nC00 = 0 To .Rows(nR00 + nRR00 - 1).Cells.Length - nCC00
  31.                 sTemp(nR00, nC00) = .Rows(nR00 + nRR00 - 1).Cells(nC00 + nCC00 - 1).innerText
  32.             Next nC00
  33.         Next nR00
  34.     End With
  35. Err1:
  36.     GetWebTb1 = sTemp
  37.     oXml.abort
  38.     oDoc.Close
  39.     Set oXml = Nothing
  40.     Set oDoc = Nothing
  41.     Set oE = Nothing
  42. End Function
½Æ»s¥N½X

TOP

        ÀR«ä¦Û¦b : ¤H­n¦Û·R¡A¤~¯à·R´¶¤Ñ¤Uªº¤H¡C
ªð¦^¦Cªí ¤W¤@¥DÃD