我想在 https://mis.twse.com.tw/stock/sblInquiryCap.jsp?lang=en_us#中捕获表中的完整数据集
我正在使用另一篇文章中的代码,但由于分页符,我只能获取前 10 个数据。无论如何,我可以修改代码以捕获完整的数据集吗?
Option Explicit
Public Sub MakeSelectionGetData()
Sheets("Sheet1").Cells.Clear
Dim ie As New InternetExplorer
Const url = "https://mis.twse.com.tw/stock/sblInquiryCap.jsp?lang=en_us#"
Application.ScreenUpdating = False
With ie
.Visible = True
.navigate url
While .Busy Or .readyState < 4: DoEvents: Wend
Application.Wait Now + TimeSerial(0, 0, 6)
Dim nTable As HTMLTable
Set nTable = .document.getElementById("sblCapTable")
Dim Headers()
Headers = Array("Number", "Stock Code", "Real Time Available Volume for SBL Short Sales", "Last Modify")
Dim TR As Object, TD As Object, r As Long, c As Long
With ActiveSheet
r = 2
c = 1
Dim TR_col As Object, TD_col As Object
Set TR_col = nTable.getElementsByTagName("TR")
.Range("A1").Resize(1, UBound(Headers) + 1) = Headers
For Each TR In TR_col
Set TD_col = TR.getElementsByTagName("TD")
For Each TD In TD_col
.Cells(r, c) = TD.innerText
c = c + 1
Next
c = 1
r = r + 1
Next
End With
.Quit
End With
Application.ScreenUpdating = True
End Sub