excelvbaseleniumweb-scrapinggetelementsbytagname

VBA Selenium: How to Extract <!-- p> non-displayed comment text, from a Web Page Element


from web page HTML

I am doing a county property survey. The mailing address is included on each record/webpage as a non-displayed comment <!-- p> with a p tag I am trying to extract those non non-displayed comments which contain the mailing and physical address of the property (see attached jpeg)

I have tried various forms of comment and attribute schemes to add on to the CSS and xPath Selectors for the h2 header above the comments - but no go so far

Set Mailing = MyBrowser.FindElementsByCss("#lxT413 > table > tbody > tr:nth-child(2) > td > h2) Set Mailing = MyBrowser.FindElementByXPath("//*[@id="lxT413"]/table/tbody/tr[2]/td/h2")


Solution

  • I got it!!!

    Set Mailing = MyBrowser.FindElementByCss("#lxT413 > table > tbody > tr:nth-child(2) > td")

    Debug.Print Mailing.Attribute("outerHTML")