I am using VBScript and getElementsByClassName
to get data from HTML to Excel. Unfortunately, a site has changed their coding, so now I am unsure how to get the data in the class, since it is now divided into several parts.
The page source looks like this:
<span class="mod-tearsheet-recommendation__visual__column">
<i data-recommendation-count="5" style="background-color:#458B00; height:25%"></i>
<i data-recommendation-count="2" style="background-color:#74A840; height:10%"></i>
<i data-recommendation-count="11" style="background-color:#777777; height:55%"></i>
<i data-recommendation-count="2" style="background-color:#DF6060; height:10%"></i>
<i data-recommendation-count="0" style="background-color:#CC0000; height:0%"></i>
</span>
I am interested only in the values 5, 2, 11, 2, 0.
http://markets.ft.com/data/equities/tearsheet/forecasts?s=MMM:NYQ
I use getElementByClassname
like this:
ws.Range("V2").Value = objExplorer.document.getElementsByClassName("mod-tearsheet-recommendation__visual__column")(1).innerHtml
But this doesn't separate the values in the class.
Is there a way to get each "i data-recommendation-count"-value in the class?
getElementsByClassName("mod-tearsheet-recommendation__visual__column")
is returning a collection of span elements which are items of the collection. Each of the span's has 5 childNodes. Each item in the childNodes collection has adata-recommendation-count
attribute.I show you three ways to reference the
data-recommendation-count
values in my code below. The way that I located these values was to set a break point after each reference and then drilled down into the reference's properties in the locals window. Next I would try test these properties in the imediate window.