Help! Need help capturing HTML data using msxml2

ski2004_2005

New Member
Joined
Apr 12, 2017
Messages
3
Default Need help with MSXML2.serverXMLHTTP request
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;">
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.
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Your code works fine for me but those values are blank on that website right now. What is you problem with the code?

WBD
 
Upvote 0
Your code works fine for me but those values are blank on that website right now. What is you problem with the code?

WBD

Thanks for the reply. The values really aren't blank. It returns blank but if you actually go to the site, the values are there in the "on the air" section. If I open an instance of internet explorer, I can get the artist and song but then I have to wait for the page to load and for what I'm trying to do, I can't wait that long. So I guess that's the problem with code.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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