ski2004_2005
New Member
- Joined
- Apr 12, 2017
- Messages
- 3
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", "http://www.siriusxm.com/siriusxmhits1", 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;">
<code> div class="module-content theme-color-content-bg clearfix">
div id="onair-pdt" style="display: block;">
img alt="" src="//www.siriusxm.com/albumart/Live/2000/chainsmokers_58C328AC_t.jpg">
p class="onair-pdt-artist">Chainsmokers/Coldplay
p class="onair-pdt-song">Something Just Like This
--------------------------------------------------------
Thanks in advance.</code>
-----------------------------------------
Dim getArtist As Object
Dim getSong As Object
Set xmHtml = New HTMLDocument
With CreateObject("MSXML2.serverXMLHTTP")
.Open "GET", "http://www.siriusxm.com/siriusxmhits1", 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;">
<code> div class="module-content theme-color-content-bg clearfix">
div id="onair-pdt" style="display: block;">
img alt="" src="//www.siriusxm.com/albumart/Live/2000/chainsmokers_58C328AC_t.jpg">
p class="onair-pdt-artist">Chainsmokers/Coldplay
p class="onair-pdt-song">Something Just Like This
--------------------------------------------------------
Thanks in advance.</code>