- ©«¤l
- 44
- ¥DÃD
- 4
- ºëµØ
- 0
- ¿n¤À
- 84
- ÂI¦W
- 0
- §@·~¨t²Î
- winxp
- ³nÅ骩¥»
- sp2
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2016-10-12
- ³Ì«áµn¿ý
- 2021-11-10
|
¦^´_ 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¾an§ì¨úªº²Ä¤@¦C¦³´XÓÄæ¦ì, Yn±q²Ä¤@¦C¶}©l§ì, §A¦Û¤vn¦A§ï¤@¤U)
¼g¤@¬qµ{¦¡µ¹function»Ýnªº¸ê°T¡A¦A§âfunction¶Ç¦^ªº¸ê®Æ¡A¿é¥X¨ìexcel¬¡¶ªí¡A°Ñ¦Ò¦p¤U- Sub main()
- Dim URL$, VV As Boolean, AB() As String
- URL = "http://www.twse.com.tw/exchangeReport/MI_INDEX?response=html&date=20170609&type=MS"
- AB = GetWebTb1(URL, 1, 2, 1, VV)
- If VV = True Then ActiveSheet.Range("A1:E63") = AB
- End Sub
- Private Function GetWebTb1(sURL00$, nTT00%, nRR00%, nCC00%, bRd00 As Boolean)
- '===sURL00 ¬°Â^¨úºô§}
- '===nTT00 ¬°Åª¨ú²Ä´XÓTable(±q1¶}©l)
- '===nRR00 ¸ÓTable¥Ñ²Ä´X¦C¶}©lŪ¨ú(±q1¶}©l)
- '===nCC00 ¸ÓTable¥Ñ²Ä´XÄæ¶}©lŪ¨ú(±q1¶}©l)
- '===bRd00 ¸Ó¸ê®Æ¬O§_¿é¥X
- Dim nR00%, nC00%, sTemp() As String, oXml As Object, oDoc As Object, oE As Object, tt As Date
- Set oXml = CreateObject("MSXML2.XMLHTTP.6.0")
- Set oDoc = CreateObject("HTMLFile")
- bRd00 = True
- rSend:
- tt = Now() + TimeValue("0:00:20")
- With oXml
- .Open "Get", sURL00, True
- .setRequestHeader "Content-type", "application/x-www-form-urlencoded"
- .send
- On Error Resume Next
- Do While .ReadyState <> 4 Or .Status <> 200
- DoEvents
- If Now > tt Then GoTo rSend
- Loop
- On Error GoTo 0
- oDoc.write .responseText
- End With
- If oDoc.all.tags("Table")(nTT00 - 1) Is Nothing Then bRd00 = False: GoTo Err1
- Set oE = oDoc.all.tags("Table")(nTT00 - 1)
- With oE
- ReDim sTemp(.Rows.Length - nRR00, .Rows(nRR00 - 1).Cells.Length - nCC00)
- For nR00 = 0 To .Rows.Length - nRR00
- For nC00 = 0 To .Rows(nR00 + nRR00 - 1).Cells.Length - nCC00
- sTemp(nR00, nC00) = .Rows(nR00 + nRR00 - 1).Cells(nC00 + nCC00 - 1).innerText
- Next nC00
- Next nR00
- End With
- Err1:
- GetWebTb1 = sTemp
- oXml.abort
- oDoc.Close
- Set oXml = Nothing
- Set oDoc = Nothing
- Set oE = Nothing
- End Function
½Æ»s¥N½X |
|