Sub GetAllValuesFromTbody()
Dim http As Object
Dim html As Object
Dim tableElement As Object
Dim rowElements As Object
Dim cellElement As Object
Dim i As Integer, j As Integer
Dim cellText As String
' Create XMLHTTP object
Set http = CreateObject("MSXML2.XMLHTTP")
' Send HTTP GET request to the website
http.Open "GET", "http://quote.eastmoney.com/SZ000010.html", False
http.send
' Create HTMLDocument object
Set html = CreateObject("HTMLFILE")
' Load the response text into HTMLDocument object
html.body.innerHTML = http.responseText
' Get the table containing the stock prices
Set tableElement = html.getElementsByClassName("quote2l_cr2_c mt10")(0).getElementsByClassName("sider_brief")(0).getElementsByClassName("t1")(0).getElementsByTagName("tbody")(0)
' Get all rows within the tbody
Set rowElements = tableElement.getElementsByTagName("tr")
' Loop through all rows and cells to get their text
For i = 0 To rowElements.Length - 1
For j = 0 To rowElements(i).getElementsByTagName("td").Length - 1
cellText = rowElements(i).getElementsByTagName("td")(j).innerText
' Write the cell text to the worksheet, starting from A1
ThisWorkbook.Sheets(1).Cells(i + 1, j + 1).Value = cellText
Next j
Next i
End Sub
Dim http As Object
Dim html As Object
Dim tableElement As Object
Dim rowElements As Object
Dim cellElement As Object
Dim i As Integer, j As Integer
Dim cellText As String
' Create XMLHTTP object
Set http = CreateObject("MSXML2.XMLHTTP")
' Send HTTP GET request to the website
http.Open "GET", "http://quote.eastmoney.com/SZ000010.html", False
http.send
' Create HTMLDocument object
Set html = CreateObject("HTMLFILE")
' Load the response text into HTMLDocument object
html.body.innerHTML = http.responseText
' Get the table containing the stock prices
Set tableElement = html.getElementsByClassName("quote2l_cr2_c mt10")(0).getElementsByClassName("sider_brief")(0).getElementsByClassName("t1")(0).getElementsByTagName("tbody")(0)
' Get all rows within the tbody
Set rowElements = tableElement.getElementsByTagName("tr")
' Loop through all rows and cells to get their text
For i = 0 To rowElements.Length - 1
For j = 0 To rowElements(i).getElementsByTagName("td").Length - 1
cellText = rowElements(i).getElementsByTagName("td")(j).innerText
' Write the cell text to the worksheet, starting from A1
ThisWorkbook.Sheets(1).Cells(i + 1, j + 1).Value = cellText
Next j
Next i
End Sub