- ©«¤l
- 161
- ¥DÃD
- 26
- ºëµØ
- 0
- ¿n¤À
- 187
- ÂI¦W
- 0
- §@·~¨t²Î
- xp
- ³nÅ骩¥»
- office 2010
- ¾\ŪÅv
- 20
- ©Ê§O
- ¨k
- ¨Ó¦Û
- TW
- µù¥U®É¶¡
- 2011-1-2
- ³Ì«áµn¿ý
- 2022-2-16
|
©ñ±ó¤FÁÙ¬O§ä¤£¨ìì¦]¡A¥Î GBKEE ¶Wª©¤j¤j msxml2.xmlhttp ªº¤èªk¥i¥H¥Î¤F¡AÁÂÁÂ
http://forum.twbts.com/thread-21270-1-2.html- Option Explicit
- Dim ie As Object '¼Ò²Õ³Ì³»ºÝ Dim ¨Ñ³o¼Ò²Õªºµ{§Ç¨Ï¥ÎªºÅܼÆ
- Sub AllFile()
- Dim i As Integer, v, Y As Integer, S As String
- Set ie = CreateObject("internetexplorer.application") '¨Ï¥Î¦¹¤è¦¡¥i¥H§K°£ "³]©w¤Þ¥Î¶µ¥Ø"
- With ie 'ÁY¤pIEµøµ¡
- .Visible = True
- .Width = 5
- .Height = 5
- End With
- With ¤u§@ªí1
- Dim AR
- AR = .Range("E1:M1")
- .Range("E:M") = ""
- .Range("E1:M1") = AR
- ' .Range("E2").CurrentRegion = "" '²M°£¤u§@ªí1,¦~«×½d³ò
- For i = 2 To .Range("A" & .Rows.Count).End(xlUp).Row
- v = .Cells(i, 1).Value
- '''''
- GetDividend (v)
- GetClosePrice (v)
- GetIncome (v)
- GetBalance (v)
- GetShareholding (v)
- .Cells(i, 5).Value = ¤u§@ªí2.Cells(5, 2).Value
- .Cells(i, 6).Value = ¤u§@ªí2.Cells(5, 3).Value
- .Cells(i, 7).Value = ¤u§@ªí3.Cells(2, 8).Value
- .Cells(i, 8).Value = .Cells(i, 5).Value / .Cells(i, 7).Value '²{ª÷´Þ§Q²v
- On Error Resume Next
- ' .Cells(i, 8).NumberFormatLocal = "0.00%"
- .Cells(i, 9).Value = ¤u§@ªí4.Cells(66, 2).Value / ¤u§@ªí5.Cells(94, 2).Value 'ROE%
- On Error Resume Next
- .Cells(i, 10).Value = ¤u§@ªí3.Cells(4, 2).Value '¥»¯q¤ñ
- .Cells(i, 11).Value = ¤u§@ªí3.Cells(12, 4).Value 'ªÑ»ù²bȤñ
- .Cells(i, 12).Value = ¤u§@ªí3.Cells(11, 4).Value 't¶Å¤ñ%
- ' .Cells(i, 12).NumberFormatLocal = "0.00%"
- .Cells(i, 13).Value = ¤u§@ªí6.Cells(3, 4).Value '¸³ºÊ«ùªÑ%
- ' .Cells(i, 13).NumberFormatLocal = "0.00%"
- Debug.Print v
- Next
- End With
- With ie 'IEµøµ¡³Ì¤j¤Æ
- Application.WindowState = xlMaximized
- .Height = Application.Height
- .Width = Application.Width
- .Quit
- End With
- End Sub
- Public Function MyFile(v As Integer, i As Integer)
- ' Dim i As Integer, v, Y As Integer, S As String
- Set ie = CreateObject("internetexplorer.application") '¨Ï¥Î¦¹¤è¦¡¥i¥H§K°£ "³]©w¤Þ¥Î¶µ¥Ø"
- With ie 'ÁY¤pIEµøµ¡
- .Visible = True
- .Width = 5
- .Height = 5
- End With
- With ¤u§@ªí1
- .Range("E" & v & ":M" & v) = ""
- ' .Range("E2").CurrentRegion = "" '²M°£¤u§@ªí1,¦~«×½d³ò
- v = .Cells(i, 1).Value
- GetDividend (v)
- GetClosePrice (v)
- GetIncome (v)
- GetBalance (v)
- GetShareholding (v)
- .Cells(i, 5).Value = ¤u§@ªí2.Cells(5, 2).Value
- .Cells(i, 6).Value = ¤u§@ªí2.Cells(5, 3).Value
- .Cells(i, 7).Value = ¤u§@ªí3.Cells(2, 8).Value
- .Cells(i, 8).Value = .Cells(i, 5).Value / .Cells(i, 7).Value '²{ª÷´Þ§Q²v
- On Error Resume Next
- ' .Cells(i, 8).NumberFormatLocal = "0.00%"
- .Cells(i, 9).Value = ¤u§@ªí4.Cells(66, 2).Value / ¤u§@ªí5.Cells(94, 2).Value 'ROE%
- On Error Resume Next
- .Cells(i, 10).Value = ¤u§@ªí3.Cells(4, 2).Value '¥»¯q¤ñ
- .Cells(i, 11).Value = ¤u§@ªí3.Cells(12, 4).Value 'ªÑ»ù²bȤñ
- .Cells(i, 12).Value = ¤u§@ªí3.Cells(11, 4).Value 't¶Å¤ñ%
- ' .Cells(i, 12).NumberFormatLocal = "0.00%"
- .Cells(i, 13).Value = ¤u§@ªí6.Cells(3, 4).Value '¸³ºÊ«ùªÑ%
- ' .Cells(i, 13).NumberFormatLocal = "0.00%"
- End With
- With ie 'IEµøµ¡³Ì¤j¤Æ
- Application.WindowState = xlMaximized
- .Height = Application.Height
- .Width = Application.Width
- .Quit
- End With
- End Function
- Private Sub GetDividend(ByVal ss As String) '¨úªÑ§Qºô¶
- Dim strText As String
- Dim i As Integer, j As Integer, xTable As Object
- With CreateObject("msxml2.xmlhttp")
- .Open "GET", "http://pscnetinvest.moneydj.com.tw/z/zc/zcc/zcc_" & ss & ".djhtm", False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .send
- strText = BinToStr(.responseBody, "BIG5") 'nª`·Nºô¶½s½X
- End With
- With CreateObject("htmlfile")
- .Write strText
- Set xTable = .all.tags("table")(2)
- With ¤u§@ªí2
- .Cells.Clear
- For i = 0 To xTable.Rows.Length - 1
- For j = 0 To xTable.Rows(i).Cells.Length - 1
- .Cells(i + 1, j + 1) = xTable.Rows(i).Cells(j).innertext
- Next
- Next
- End With
- End With
- End Sub
- Private Sub GetClosePrice(ByVal ss As String) ' ¨ú°ò¥»¸ê®Æ
- Dim strText As String
- Dim i As Integer, j As Integer, xTable As Object
- With CreateObject("msxml2.xmlhttp")
- .Open "GET", "http://pscnetinvest.moneydj.com.tw/z/zc/zca/zca_" & ss & ".djhtm", False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .send
- strText = BinToStr(.responseBody, "BIG5") 'nª`·Nºô¶½s½X
- End With
- With CreateObject("htmlfile")
- .Write strText
- Set xTable = .all.tags("table")(2)
- With ¤u§@ªí3
- .Cells.Clear
- For i = 0 To xTable.Rows.Length - 1
- For j = 0 To xTable.Rows(i).Cells.Length - 1
- .Cells(i + 1, j + 1) = xTable.Rows(i).Cells(j).innertext
- Next
- Next
- End With
- End With
- End Sub
- Private Sub GetIncome(ByVal ss As String) '¨ú·l¯qªí(¦~ªí)ºô¶
- Dim strText As String
- Dim i As Integer, j As Integer, xTable As Object
- With CreateObject("msxml2.xmlhttp")
- .Open "GET", "http://kgieworld.moneydj.com/z/zc/zcq/zcqa/zcqa_" & ss & ".djhtm", False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .send
- strText = BinToStr(.responseBody, "BIG5") 'nª`·Nºô¶½s½X
- End With
- With CreateObject("htmlfile")
- .Write strText
- Set xTable = .all.tags("table")(2)
- With ¤u§@ªí4
- .Cells.Clear
- For i = 0 To xTable.Rows.Length - 1
- For j = 0 To xTable.Rows(i).Cells.Length - 1
- .Cells(i + 1, j + 1) = xTable.Rows(i).Cells(j).innertext
- Next
- Next
- End With
- End With
- End Sub
- Private Sub GetBalance(ByVal ss As String) '¨ú¸ê²£t¶Åªí(¦~ªí)ºô¶
- Dim strText As String
- Dim i As Integer, j As Integer, xTable As Object
- With CreateObject("msxml2.xmlhttp")
- .Open "GET", "http://kgieworld.moneydj.com/z/zc/zcp/zcpb/zcpb_" & ss & ".djhtm", False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .send
- strText = BinToStr(.responseBody, "BIG5") 'nª`·Nºô¶½s½X
- End With
- With CreateObject("htmlfile")
- .Write strText
- Set xTable = .all.tags("table")(2)
- With ¤u§@ªí5
- .Cells.Clear
- For i = 0 To xTable.Rows.Length - 1
- For j = 0 To xTable.Rows(i).Cells.Length - 1
- .Cells(i + 1, j + 1) = xTable.Rows(i).Cells(j).innertext
- Next
- Next
- End With
- End With
- End Sub
- Private Sub GetShareholding(ByVal ss As String) '¨ú¸³ºÊ«ùªÑºô¶
- Dim strText As String
- Dim i As Integer, j As Integer, xTable As Object
- With CreateObject("msxml2.xmlhttp")
- .Open "GET", "http://pscnetinvest.moneydj.com.tw/z/zc/zcj/zcj_" & ss & ".djhtm", False
- .setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
- .send
- strText = BinToStr(.responseBody, "BIG5") 'nª`·Nºô¶½s½X
- End With
- With CreateObject("htmlfile")
- .Write strText
- Set xTable = .all.tags("table")(3)
- With ¤u§@ªí6
- .Cells.Clear
- For i = 0 To xTable.Rows.Length - 1
- For j = 0 To xTable.Rows(i).Cells.Length - 1
- .Cells(i + 1, j + 1) = xTable.Rows(i).Cells(j).innertext
- Next
- Next
- End With
- End With
- End Sub
- Function BinToStr(arrBin, strChrs)
- With CreateObject("ADODB.Stream")
- .Type = 2
- .Open
- .Writetext arrBin
- .Position = 0
- .Charset = strChrs
- BinToStr = .ReadText
- .Close
- End With
- End Function
½Æ»s¥N½X |
|