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

Time:12-04

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")

CodePudding user response:

Have a look here. Also looking at the screenshot you've provided, it seems that the commented portion of the DOM is not inside the h2 element but rather inside the td element, maybe that is the reason why you can't reach it?

CodePudding user response:

I got it!!!

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

Debug.Print Mailing.Attribute("outerHTML")

  • Related