Почему, когда я извлекаю таблицу с помощью метода .getElementsByTagName, он не извлекает все данные, содержащиеся в таблице? Обратите внимание, что это прокрутка вниз на странице https://finance.yahoo.com/quote/MGLU3.SA/history?p=MGLU3.SA.
Public Sub getHistoricCotation()
Dim mainURL As String
Dim elem As Object, tRow As Object
Dim S, R, C
Dim initial_date As String, final_date As String
Dim stock As String
initial_date = DateDiff("s", "1/1/1970 00:00:00", ufHistorico.txtDtInicial) + 86400
final_date = DateDiff("s", "1/1/1970 00:00:00", ufHistorico.txtDtFinal) + 86400
stock = ufHistorico.cbAcoes.Text
mainURL = "https://finance.yahoo.com/quote/" & stock & "/history?period1=" & initial_date & "&period2=" & final_date & "&interval=1d&filter=history&frequency=1d"
With CreateObject("WinHttp.WinHttpRequest.5.1")
.Open "GET", mainURL, False
strCookie = .getAllResponseHeaders
strCookie = Split(Split(strCookie, "Cookie:")(1), ";")(0)
.Open "GET", mainURL, False
.setRequestHeader "Cookie", strCookie
.setRequestHeader "User-Agent", "Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
.send
S = .responseText
End With
With CreateObject("htmlfile")
.body.innerHTML = S
For Each elem In .getElementsByTagName("tr")
For Each tRow In elem.Cells
C = C + 1: Cells(R + 1, C) = tRow.innerText
Next tRow
C = 0: R = R + 1
Next elem
End With
End Sub