| ©«¤l5923 ¥DÃD13 ºëµØ1 ¿n¤À5986 ÂI¦W0  §@·~¨t²Îwin10 ³nÅ骩¥»Office 2010 ¾\ŪÅv150 ©Ê§O¨k ¨Ó¦Û¥xÆW°ò¶© µù¥U®É¶¡2010-5-1 ³Ì«áµn¿ý2022-1-23 
         
 | 
                
| ¦^´_ 1# jerrystock ¥u§ä¨ì Ӫѥ»¯q¤ñ ªººô§}°Ñ¼Æ
 http://www.otc.org.tw/web/stock/ ... ?d=103/10/07&c=
 
 ¸Õ¸Õ¬Ý
 ½Æ»s¥N½XOption Explicit
Const ¥»¯q¤ñ = "http://www.otc.org.tw/web/stock/aftertrading/peratio_analysis/pera.php"
Const ¥»¯q¤ñdownload = "http://www.otc.org.tw/web/stock/aftertrading/peratio_analysis/pera_download.php?d="
Dim xDate As Date, Stk As String
Private Sub Ӫѥ»¯q¤ñ_´Þ§Q²v¤ÎªÑ»ù²bȤñ_¨Ì¤é´Á¬d¸ß()
    Dim s As String, E As Variant, A
    xDate = Date - 1
    Do Until Weekday(xDate, vbFriday) < 6
        xDate = xDate - 1
    Loop
    With CreateObject("InternetExplorer.Application")
        .Visible = True
       .Navigate ¥»¯q¤ñ
        Do While .Busy Or .ReadyState <> 4: DoEvents: Loop
        With .document
            '¸ê®Æ¤é´Á¡G<input id="input_date" name="input_date" class="input-date ui-corner-all" onchange="query()" maxlength="6">
            .ALL("input_date").Value = Format(xDate, "E/MM/DD")  '
            'D = .ALL("input_date").Value
            '²£·~Ãþ§O¡G<select id="stk_category" class="input-stk-cat ui-corner-all" onchange="query()">
            .ALL("stk_category").Item(0).Selected = True '¥þ³¡
            '.ALL("stk_category").Item(8).Selected = True '²Ä 9(0 -> 8) ¶µ
            Stk = .ALL("stk_category").Value
           ' .ALL("stk_category").fireEvent ("onchange")
            With .ALL("stk_category")
                For E = 0 To .Length - 1
                    If .Item(E).Value = .Value Then Stk = .Item(E).Value & " " & .Item(E).INNERTEXT
                    s = IIf(s = "", .Item(E).Value & " " & .Item(E).INNERTEXT, s & vbLf & .Item(E).Value & " " & .Item(E).INNERTEXT)
                Next
            End With
        End With
        MsgBox "§A¿ï¾Ü:  " & Stk & vbLf & vbLf & s, , "²£·~Ãþ§O"
        .Quit
    End With
    ¸ü¤JCSV
End Sub
Private Sub ¸ü¤JCSV()
    Dim xml As Object     '¥Î¨Ó¨ú±oºô¶¸ê®Æ
    Dim stream            '¥Î¨ÓÀx¦s¤G¶i¦ìÀÉ®×
    Dim URL As String     '¥Øªººô§}
    Dim xPath As String, xfile As String, W As Workbook
    xPath = "d:\"         '«ü©w¦sÀɸô®|
    xfile = xPath & Replace(Format(xDate, "E/MM/DD"), "/", "_") & " " & Split(Stk, " ")(1) & ".csv"
    For Each W In Workbooks
        If UCase(W.FullName) = UCase(xfile) Then W.Close: Exit For
    Next
    Set xml = CreateObject("Microsoft.XMLHTTP")
    Set stream = CreateObject("ADODB.stream")
    URL = ¥»¯q¤ñdownload & Format(xDate, "E/MM/DD") & "&c=" & Split(Stk, " ")(0)
        xml.Open "POST", URL, 0
        xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
        xml.send
    With stream
        .Open
        .Type = 1
        .write xml.ResponseBody
        If Dir(xfile) <> "" Then Kill xfile
        .SaveToFile (xfile)
        .Close
    End With
    With Workbooks.Open(xfile).Sheets(1)
        If .Range("A5") = "¦@0µ§" Then
            .Parent.Close
            Kill xfile
            MsgBox xDate & " - " & Stk & " ¨S¦³¸ê®Æ"
        Else
            MsgBox xDate & " - " & Stk & Space(5) & .Cells(1).End(xlDown) & "¸ê®Æ"
        End If
    End With
End Sub
 | 
 |