from lxml.html import etree content = "***************" html = etree.HTML(str(content)) html_data = html.xpath('//span/text()|//p//text()|//section//text()') datas = [data.replace("/r", "").replace("/n", '').replace('/t', '').replace('/xa0', '') for data in list(html_data)] ori_content = ' '.join([d for d in datas if d])
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/tech/python/279068.html