Need help with MSXML2.serverXMLHTTP request

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>
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,225,757
Messages
6,186,845
Members
453,379
Latest member
gabriellegonzalez

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top