¦U¦ì°ª¤â¦n
¤p©f vba¤p¹à¹à,³o¬qµ{¦¡¦³¤°³Â¤è¦¡¥iקï Åý¥L¤£·|¥d¦í,¨DÀ°¦£!!!·PÁÂ- Sub stock()
- Dim oXMLHTTP As Object
- Dim sPageHTML As String
- Dim sURL As String '«e±¤T¶µÅܼƥ²key
- a = 0
- Do
- a = a + 1
- Select Case a
- Case 1
- sURL = "https://tw.stock.yahoo.com/q/q?s=" & Sheets(3).Cells(36, 6) '³sµ²ªÑ²¼¥N¸¹
- Case 2
- sURL = "https://tw.stock.yahoo.com/q/q?s=" & Sheets(3).Cells(37, 6)
-
-
- End Select
- Set oXMLHTTP = CreateObject("MSXML2.ServerXMLHTTP")
- oXMLHTTP.Open "GET", sURL, False
- oXMLHTTP.send
- sPageHTML = oXMLHTTP.responseText
-
- Select Case a
- Case 1
- Sheets(5).Cells(1, 1) = sPageHTML '±Nºô¶¸ê°T¶K¨ì³oÓ¦ì¸m
- Case 2
- Sheets(5).Cells(1, 2) = sPageHTML
-
-
-
- End Select
- If a = 2 Then
- Exit Do
- End If
-
- Loop
-
- aaa = Sheets(5).Cells(1, 1) 'ºô§}¸ô®|aaa
-
- aaalen = Len(aaa) 'len¨úºô¶¸ê°T
-
-
- yy = 0
- Y = 1
- For t = 1 To aaalen '¨ìºô¶§ä¯S¼x¸ê®Æ¨ÓÂ^¨ú§ÚÌnªº¸ê®Æ
-
- If Mid(aaa, t, Len("nowrap")) = "nowrap" Then '¯S¼xnowrap n¥h¤å¦rÀÉ·j´Mºô¶¯S¼x
-
-
- cc = 0
-
- t = t + Len("nowrap")
- q1 = ""
-
- Do
- If Mid(aaa, t, 1) = ">" Then 'aaaºô¸ô¸ô®|¸ê®Æ,²ÄtÓȨú²Ä¤@µ§¸ê®Æ
- q1 = ""
- cc = 1
- yy = yy + 1
- Y = Y + 1
- If yy = 2 Then 'yy¬°²Ä´Xµ§¸ê®Æ
- t = t + 4 '±q¯S¼x¸ê®Æ¨ì§AnÂ^¨úªº¸ê®Æn¥[¦h¤Ö
- ElseIf yy = 5 Then
- t = t + 21
- Else
- t = t + 1
- End If
- End If
- If Mid(aaa, t, 1) = "<" Then
- If yy = 5 Then
- Sheets(4).Cells(2, Y) = Left(RTrim(LTrim(q1)), Len(RTrim(LTrim(q1))) - 1) '±N¸ÓÄæ¸ê®Æ¸m¤¤
-
- Else
- Sheets(4).Cells(2, Y) = RTrim(LTrim(q1))
-
- End If
- q1 = ""
- cc = 0
- Exit Do
- End If
- If cc = 1 Then
- q1 = q1 & Mid(aaa, t, 1)
- End If
- t = t + 1
- Loop
-
- End If
-
-
-
- bbb = Sheets(5).Cells(1, 2) 'ºô§}¸ô®|aaa
- bbblen = Len(bbb) 'len¨úºô¶¸ê°T
- yy = 0
- Y = 1
- For i = 1 To bbblen '¨ìºô¶§ä¯S¼x¸ê®Æ¨ÓÂ^¨ú§ÚÌnªº¸ê®Æ
- If Mid(bbb, i, Len("nowrap")) = "nowrap" Then '¯S¼xnowrap n¥h¤å¦rÀÉ·j´Mºô¶¯S¼x
- cc = 0
- i = i + Len("nowrap")
- q1 = ""
- Do
- If Mid(bbb, i, 1) = ">" Then 'aaaºô¸ô¸ô®|¸ê®Æ,²ÄtÓȨú²Ä¤@µ§¸ê®Æ
- q1 = ""
- cc = 1
- yy = yy + 1
- Y = Y + 1
- If yy = 2 Then 'yy¬°²Ä´Xµ§¸ê®Æ
- i = i + 4 '±q¯S¼x¸ê®Æ¨ì§AnÂ^¨úªº¸ê®Æn¥[¦h¤Ö
- ElseIf yy = 5 Then
- i = i + 21
- Else
- i = i + 1
- End If
- End If
- If Mid(bbb, i, 1) = "<" Then
- If yy = 5 Then
- Sheets(4).Cells(3, Y) = Left(RTrim(LTrim(q1)), Len(RTrim(LTrim(q1))) - 1) '±N¸ÓÄæ¸ê®Æ¸m¤¤
- Else
- Sheets(4).Cells(3, Y) = RTrim(LTrim(q1))
- End If
- q1 = ""
- cc = 0
- Exit Do
- End If
- If cc = 1 Then
- q1 = q1 & Mid(bbb, i, 1)
- End If
- i = i + 1
- Loop
- End If
- Next i
- Next t
-
- End Sub
½Æ»s¥N½X |