- ©«¤l
- 519
- ¥DÃD
- 54
- ºëµØ
- 0
- ¿n¤À
- 595
- ÂI¦W
- 260
- §@·~¨t²Î
- win 10
- ³nÅ骩¥»
- []
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-3-19
- ³Ì«áµn¿ý
- 2024-11-28
|
¦^´_ 6# zheng211016
½Ðª`·N°Ñ¦Ò¬õ¦rªº³¡¤À¡A°}¦C±q 1 ¶}©l¡G
Option Base 1
Sub byXMLhttp_Test2()
Dim sh As Worksheet
Dim t!, i%, j%, k%
Dim myXML As Object, myHTML As Object, myTable, arDATA, URL$
URL = "https://histock.tw/stock/financial.aspx?no=3032&t=2"
Set sh = Worksheets("¸ÕÅç¶")
Set myXML = CreateObject("Microsoft.XMLHTTP")
Set myHTML = CreateObject("HTMLFile")
sh.Cells.Clear
With myXML
.Open "GET", URL, False
.send
If .Status <> 200 Then MsgBox "No successful web connection", vbOKOnly: Exit Sub
myHTML.body.innerhtml = .responsetext
End With
Set myTable = myHTML.getelementsbytagname("TABLE")(0)
With myTable
i = .Rows.Length: j = .Rows(0).Cells.Length
ReDim arDATA(i, j)
k = 0 '
For i = 1 To .Rows.Length
If .Rows(i - 1).innertext <> "" Then
k = k + 1
For j = 1 To .Rows(0).Cells.Length
Cells(k, j) = .Rows(i - 1).Cells(j - 1).innertext
arDATA(k, j) = .Rows(i - 1).Cells(j - 1).innertext
Next
End If
Next
End With
sh.[A15].Resize(UBound(arDATA), UBound(arDATA, 2)) = arDATA
Set myXML = Nothing
Set myHTML = Nothing
Set myTable = Nothing
End Sub |
|