我正在清理爬网网站上的文本,但我不想在我的数据中包含任何html注释,所以我必须自己解析它,还是有一个现有的函数可以这样做
我试过这样做:
from bs4 import BeautifulSoup as S
soup = S("<!-- t --> <h1>Hejsa</h1> <style>html{color: #0000ff}</style>")
soup.comment # == None
soup.style # == <style>html{color: #0000ff}</style>
Tags:
要搜索表单HTML注释,可以使用
bs4.Comment
类型:印刷品:
要提取它,请执行以下操作:
印刷品:
使用正则表达式
结果:
相关问题 更多 >
编程相关推荐