Query div element by class name using Excel VBA
问题 I'm trying to get the data to Excel of a div element with a specific class name, like: <div class="myClass"> <span>Text1</span> <span>Text2</span> </div> My VBA code: Sub GetData() Dim oHtml As HTMLDocument Dim oElement As Object Set oHtml = New HTMLDocument With CreateObject("WINHTTP.WinHTTPRequest.5.1") .Open "GET", "http://www.example.com/", False .send oHtml.body.innerHTML = .responseText End With For Each oElement In oHtml.getElementsByClassName("myClass") Debug.Print oElement.Children(0