PYTHON 提取HTML文本
作者:互联网
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])
标签:PYTHON,text,html,replace,content,HTML,文本,data 来源: https://www.cnblogs.com/cupleo/p/16554477.html