html - Loop through multiple divs using VBA -
i trying extract information html page using vb script. html page trying extract information.
<div id="profile-education"> <div class="position first education vevent vcard" id="xxxxxx"> university 1 <span class="degree">ph.d.</span> <span class="major">computer science</span> <p class="period"> <abbr class="dtstart" title="2005-01-01">2005</abbr> – <abbr class="dtend" title="2012-12-31">2012</abbr> </div> <div class="position education vevent vcard" id="xxxxxx"> university 2 <span class="degree">m.eng.</span> <span class="major">computer science</span> <p class="period"> <abbr class="dtstart" title="2000-01-01">2000</abbr> – <abbr class="dtend" title="2004-12-31">2004</abbr> </p> </div> </div>
i want extract information in below format.
- university name: university 1
- degree name: phd
- major: computer science
period: 2005 - 2012
university name: university 2
- degree name: m.eng
- major: computer science
- period: 2000 - 2004
in vb script, have following code extracts entire information single variable.
dim openedpage string openedpage = iedoc1.getelementbyid("profile-education").innertext
however, if use following statement in vb script, can particular span information.
openedpage = iedoc1.getelementbyid("profile-education").getelementsbytagname("span") (0).innertext
the above code gives me phd output. however, not know total spans beforehand , cannot give span(0) , span(1) in code. also, extract information div tags , won't knowing information either. basically, want loop structure iterate through div tags id profile-education should able extract multiple div , span information.
dim divs, div set divs = iedoc1.getelementbyid("profile-education").getelementsbytagname("div") each div in divs debug.print "*************************************" debug.print div.childnodes(0).tostring debug.print div.getelementsbytagname("span")(0).innertext debug.print div.getelementsbytagname("span")(1).innertext ' etc... next div
Comments
Post a Comment