Filtering out content with style display:none in an XPath expression -
i'm trying parse lxml in python , output
<td> <span style="display:inline">text1</span> <span style="display:none">text2</span> <span>text3</span> text4 </td> thought smart enough use following
tree = tr.xpath("//*[contains(@style,'inline')]/text()") but thought see text1. want see text3 , text4 output be
['text1', 'text3', 'text4']
can send me right direction of doing it?
explicitly exclude display:none:
tree = tr.xpath("//*[not(contains(@style,'display:none'))]/text()") that said -- distant approximation of browser do; you'd want driving actual browser (as selenium, embedding apis, or like) if required strictly accurate results.
Comments
Post a Comment