arrays - vba: getElementsByClassName with different class names -


i working on excel sheet, collects data website. few words website:
- independant me, can not change struckture
- should table, not. structure this:

<h4>blabla</h4><span class="address">blabla</span><span class="state_x">blabla</span> <h4>blabla</h4><span class="address">blabla</span><span class="state_x">blabla</span> <h4>blabla</h4><span class="address">blabla</span><span class="state_y">blabla</span> 

the trick "state_?" class, name can change (but end of it).

what doing now?
- collect data arrays
- of course "state_x" , "state_y" arrays
- go through arrays, , write sheet

the problem: when "state_?" arrays, don't know, data came from. best have 1 "state" array, can collect data "state_?" classes. of course code doesn't work, show logic:

dim state variant set state = ieapp.document.getelementsbyclassname("state_*") 

how work? appreciated, please consider, new in vba.

new infos

i have found further analysing source html code. each row nested in <div class="listitem"> </div>. possible create array, each element complete "listitem" div, , loop extract data these elements, written above?

each "listitem" div can contain 1 "state_?" class. way wouldn't loose information, data comes from.

try queryselectorall selector e.g. "*[class^='state_']" should select elements have class name starts text state_. more selectors here. hth

dim states ihtmldomchildrencollection set doc = ie.document set states = doc.queryselectorall("*[class^='state_']")  if (not states nothing)    dim    = 0 states.length - 1     debug.print states(i).innerhtml    next end if     

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -