Ski2004_2005
04-13-2017, 04:18 AM
Hi. I think I'm close and have googled until the cows come home. I need to return a "p class" value from a series of websites. My code currently reads:
-----------------------------------------
Dim getArtist As Object
Dim getSong As Object
Set xmHtml = New HTMLDocument
With CreateObject("MSXML2.serverXMLHTTP")
.Open "GET", URL, False
.send
xmHtml.body.innerHTML = .responseText
End With
Set getArtist = xmHtml.getElementById("onair-pdt").getElementsByTagName("p")(0)
MsgBox (getArtist.innerText)
Set getSong = xmHtml.getElementById("onair-pdt").getElementsByTagName("p")(1)
MsgBox (getSong.innerText)
--------------------------------------
I have also tried WINHTTP.WinHTTPRequest.5.1. I can return the values by opening Internet Explorer and navigating to the page but it takes far too long for what I need to do. The main difference is I can refer to the getElementsByClassName when opening Internet Explorer but can't with MSXML2.
The HTML for this example is shown below. What I need is the innertext values of p class "onair-pdt-artist" and "onair-pdt-song":
-------------------------------------------------------------------
div id="on-the-air-content" style="display: block;">
div class="module-content theme-color-content-bg clearfix">
div id="onair-pdt" style="display: block;">
p class="onair-pdt-artist">Chainsmokers/Coldplay
p class="onair-pdt-song">Something Just Like This
--------------------------------------------------------
Thanks in advance.
-----------------------------------------
Dim getArtist As Object
Dim getSong As Object
Set xmHtml = New HTMLDocument
With CreateObject("MSXML2.serverXMLHTTP")
.Open "GET", URL, False
.send
xmHtml.body.innerHTML = .responseText
End With
Set getArtist = xmHtml.getElementById("onair-pdt").getElementsByTagName("p")(0)
MsgBox (getArtist.innerText)
Set getSong = xmHtml.getElementById("onair-pdt").getElementsByTagName("p")(1)
MsgBox (getSong.innerText)
--------------------------------------
I have also tried WINHTTP.WinHTTPRequest.5.1. I can return the values by opening Internet Explorer and navigating to the page but it takes far too long for what I need to do. The main difference is I can refer to the getElementsByClassName when opening Internet Explorer but can't with MSXML2.
The HTML for this example is shown below. What I need is the innertext values of p class "onair-pdt-artist" and "onair-pdt-song":
-------------------------------------------------------------------
div id="on-the-air-content" style="display: block;">
div class="module-content theme-color-content-bg clearfix">
div id="onair-pdt" style="display: block;">
p class="onair-pdt-artist">Chainsmokers/Coldplay
p class="onair-pdt-song">Something Just Like This
--------------------------------------------------------
Thanks in advance.