Hi everyone,
I'm trying to get VBA to scrape info from a website and I have gotten most of the way through but I am struggling to loop through several layers of nesting.
The HTML code looks roughly like this:
div class: "group 1"
div class: "group main"
span class: "group main title"
table class: "group table"
td class: "group properties"
div class: "group 2"
<tbody>
</tbody>
I'm trying to get VBA to scrape info from a website and I have gotten most of the way through but I am struggling to loop through several layers of nesting.
The HTML code looks roughly like this:
div class: "group 1"
div class: "group main"
span class: "group main title"
table class: "group table"
td class: "group properties"
div class: "group 2"
with multiple groups in the main and sub div classes. I'm having a hard time referencing all of the pieces. I am able to use IE.document.getElementsByClassName("group") to cycle through the main groups but after that the sub classes are getting me messed up. I want to be able to loop through subclasses of subclasses potentially so I need help understanding the syntax. I know there is some sort of way to loop through using something like IE.document.getElementsByClassName("group")(0).getElementsByClassName("group_1_main") but I need to write if statements and pull out only specific pieces as listed above without grabbing the many elements between. I think most of my struggle is that the iHTMLElement object doesn't seem to have a good way for me to loop through (something like for i = 0 to max_count) or something. Hopefully what I'm asking isn't too confusing. |
<tbody>
</tbody>