Bootstrap

html,xpath合并P标签以下的内容

html,xpath合并P标签以下的内容,同时删除P标签下的span标签
try:
    html_selector = etree.HTML(html)
    for p in html_selector.xpath("//p"):
        p.text = "".join(p.xpath(".//text()"))
        for span in p.xpath("./span"):
            p.remove(span)
    html = etree.tostring(html_selector, encoding="unicode")
except Exception as e:
    print(e)
;