我试图摆脱的HTML标记,在一定程度上它的工作,但不是所有的标记被删除。但下面提到的标签并没有消失
print('NOT DEALT WITH:')
for body in not_dealt_with_list:
#p = re.compile(r'<.*?[\\t\\n\\r\\s]*?.*?>')
print(remove_tags(body))
#print(p.sub('', body))
#body = re.sub()
def remove_tags(content):
parser = lxml.html.HTMLParser(remove_comments=True,
remove_blank_text=True)
document = lxml.html.document_fromstring(content, parser)
return document.text_content()
看起来您要删除的内容嵌入到了一个html注释中(因为它看起来不像html)。Html注释以开头,这就是您必须搜索的内容。你知道吗
尝试使用这个正则表达式搜索注释中的所有内容,然后在多行中替换它
告诉我结果如何!你知道吗
相关问题 更多 >
编程相关推荐