powerlove2020
Yêu THVBA
mình đang cần lấy nguyên cái bảng từ web này về, hiện mình có 1 đoạn code nhưng chỉ lấy dc đúng số đầu tiên trong bảng này, ai giúp mình lấy nguyên cái bảng này về với. mình cảm ơn
Bạn cần đăng nhập để thấy link
Mã:
Sub Get_Web_Data()
' TeachExcel.com
Dim request As Object
Dim response As String
Dim html As New HTMLDocument
Dim website As String
Dim price As Range
Set price = Range("A5")
' Website to go to.
website = "https://finance.yahoo.com/quote/%5EIXIC/history?p=%5EIXIC"
' Create the object that will make the webpage request.
Set request = CreateObject("MSXML2.XMLHTTP")
' Where to go and how to go there - probably don't need to change this.
request.Open "GET", website, False
' Get fresh data.
request.setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
' Send the request for the webpage.
request.send
' Get the webpage response data into a variable.
response = StrConv(request.responseBody, vbUnicode)
' Put the webpage into an html object to make data references easier.
html.body.innerHTML = response
' Get the price from the specified element on the page.
price = html.getElementsByClassName("Py(10px) Ta(start) Pend(10px)").Item(0).innerText
' Output the price into a message box.
'set price Range("A5")
End Sub
Bạn cần đăng nhập để thấy hình ảnh
Bạn cần đăng nhập để thấy hình ảnh