- ©«¤l
- 2035
- ¥DÃD
- 24
- ºëµØ
- 0
- ¿n¤À
- 2031
- ÂI¦W
- 0
- §@·~¨t²Î
- Win7
- ³nÅ骩¥»
- Office2010
- ¾\ŪÅv
- 100
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2012-3-22
- ³Ì«áµn¿ý
- 2024-2-1
|
¦^´_ 98# zyzzyva
«D±`·PÁ§Aªº¸Ô²Ó»¡©ú¡C
¤âÀY¤W¦³¤@²{¦¨ªº Excel ½d¨Ò¡A§Ú±N¨ä¤é´Áq¬° 105¦~09¤ë08¤é¡A
À³¥Î IE ª«¥ó¥h§ì¨ú¸Ó¤éªº "«H¥Î¥æ©ö²Îp"¡C§Ú«D±`§Æ±æ¯àÂǥѦ¹½d¨Ò
¨Ï¥Î Python ¨Ó¹F¦¨¡A¤@¤è±¼Wªø´¼¼z¡B¥t¤@¤è±±o¥H¼W¶i Python ªº¾Ç²ß¡A
¤Î¶i¤@¨B¤§¤F¸Ñ»PÀ³¥Î¡C¥ý¦æÁÂÁ§AÅo¡I- Sub «H¥Î¥æ©ö²Îp()
- Dim i As Integer, j As Integer
- Dim ie As Object, E As Object, Sh As Worksheet
-
- Set ie = CreateObject("InternetExplorer.Application")
-
- With ie
- .Visible = True
- .navigate "http://www.twse.com.tw/ch/trading/exchange/MI_MARGN/MI_MARGN.php"
-
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
-
- .document.getElementById("date-field").Value = Format("2016/9/8", "EE/MM/DD") ' ¶ñ¤J
-
- .document.all("selectType").SelectedIndex = 1 ' 1 ¥þ³¡; 7 ¤ôªd¤u·~; 8 ¹«~¤u·~
- .document.all("query-button").Click
-
- Do While .Busy Or .readyState <> 4: DoEvents: Loop
-
- ' Set Sh = ActiveSheet
- Set Sh = Sheets("«H¥Î¥æ©ö²Îp") ' ¤u§@ªí³æ¦WºÙ
- Sh.UsedRange.Clear
- ' Sh.[A:A].NumberFormatLocal = "G/³q¥Î®æ¦¡" ' ¸Ñ¨M "0050" -> "50" (¤£²z·Q)
- ' Sh.[A:A].NumberFormatLocal = "@" ' ¸Ñ¨M "0050" -> "50" (¥ª¤W¨¤·|¦³¤T¨¤§Î)
-
- i = 0
- With .document
- For Each E In .all.tags("table")(3).Rows
- i = i + 1 '
- For j = 0 To E.Cells.Length - 1
- If j = 0 And Left(E.Cells(j).innerText, 1) = "0" Then ' §ï¥H .Formula ªº¤è¦¡³B²z
- Sh.Cells(i, j + 1).Formula = "=""" & E.Cells(j).innerText & """"
- Else
- Sh.Cells(i, j + 1) = E.Cells(j).innerText
- End If
- Next
- Next
-
- i = i + 1 ' ¶¡¹j¥X¤@ªÅ¥Õ¦æ¡A©ö©ó¤W¤U°Ï¹j¿ëÃÑ
- For Each E In .all.tags("table")(4).Rows
- i = i + 1 '
- For j = 0 To E.Cells.Length - 1
- If j = 0 And Left(E.Cells(j).innerText, 1) = "0" Then
- Sh.Cells(i, j + 1).Formula = "=""" & E.Cells(j).innerText & """"
- Else
- Sh.Cells(i, j + 1) = E.Cells(j).innerText
- End If
- Next
- Next
- End With
-
- .Quit
- With Sh
- .[A:A].HorizontalAlignment = xlLeft ' A ÄæÈ¥þ¼Æ¾a¥ª
- .Select
- End With
- End With
- End Sub
½Æ»s¥N½X
«H¥Î¥æ©ö²Îp.rar (51.88 KB)
|
|