I use the following code to find a div:
parser = etree.HTMLParser() tree = etree.parse(StringIO(page), parser) div = tree.xpath("//div[@class='content']")[0]
My only problem is that after that I don't want to rely on lxml to extract the contents of the specified div: I just want to return the raw XML containing the div. Is this doable or do I need to completely abandon this method?
source share