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

ÃÒ¥æ©Ò§ì­ÓªÑ¤é¦¨¥æ¸ê°T

ÃÒ¥æ©Ò§ì­ÓªÑ¤é¦¨¥æ¸ê°T

¤§«e§ì¨úÃÒ¥æ©Òªº¸ê®Æ¨S¦³°ÝÃD

¦ý¬O²{¦b·|¥X²{¡u¨t²Î§ä¤£¨ì«ü©wªº¸ê·½¡v¡AµM«á°±¦b¡uXML.send thePOSTdata¡v³o¦æµ{¦¡½X

§ä¤£¨ì¿ù»~¥X¦b­þ

ÁÂÁ¦U¦ì¤j¤j¤F


Sub «ö¶s1_Click()

Dim starttime As Variant
Dim fountrow As Integer

starttime = Now()

'Application.ScreenUpdating = False ' Ãö³¬¿Ã¹õ§ó·s¡A¥[§Ö³t«×¡C

    Set XML = CreateObject("Microsoft.XMLHTTP")
    Set Stream = CreateObject("ADODB.stream")
    Dim path As String, thePOSTdata, URL


    URL = "https://twse.com.tw/zh/page/trading/exchange/STOCK_DAY.html"
    thePOSTdata = "download=csv&query_year=2020&query_month=10&CO_ID=2330"
        XML.Open "POST", URL, 0
        XML.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

        XML.send thePOSTdata
   
With Stream
               
    .Type = 1
    .Mode = 3
    .Open
    .Write XML.responseBody
    .Position = 0
    .Type = 2
    .Charset = "Big5"
    ByteToText = .ReadText
   
    'MsgBox ByteToText

    Dim arr() As String
   
                    arr = Split(ByteToText, Chr(10))       'Chr(10)¥NªíEnterÁä¶Ü???
   
    Dim processstring As String
   
    For i = 0 To UBound(arr)
        'MsgBox arr(i)
        processstring = Replace(arr(i), """,""", "^^")
   
        'putdata = Split(arr(i), "^^")
        putdata = Split(processstring, "^^")
        


        For j = 0 To UBound(putdata)
            Sheets(1).Cells(i + 1, j + 1).NumberFormatLocal = "@"
            '¤u§@ªí1.Cells(i + 1, j + 1).Value = CStr(Replace(Replace(putdata(j), """", ""), "=", ""))
            'MsgBox putdata(j)
            ShowString = Replace(Trim(putdata(j)), ",", "")
            ShowString = Replace(ShowString, """", "")
            ShowString = Replace(ShowString, "=", "")
            Sheets(1).Cells(i + 1, j + 1).Value = ShowString
            
        Next j
    Next i

End With
End Sub

        ÀR«ä¦Û¦b : ­×¦æ­nô½t­×¤ß¡AÂǨƽm¤ß¡AÀH³B¾i¤ß¡C
ªð¦^¦Cªí ¤W¤@¥DÃD