2024-05-23 21:34:48 发布
网友
我用Python2.7编程,我用beautifulsoup4从一系列文档的标签中提取信息。但是,该文档还包含以下字符串:
<!-- PJG ITAG l=90 g=1 f=4 -->
我想摆脱它们,但是我不是regexp方面的专家。有人能帮忙吗?你知道吗
从在BeautifulSoup中加载HTML开始:
from bs4 import BeautifulSoup, Comment soup = BeautifulSoup(the_html)
然后,删除所有注释:
comments = soup.find_all(text = lambda text:isinstance(text, Comment)) for comment in comments: comment.extract()
从在BeautifulSoup中加载HTML开始:
然后,删除所有注释:
相关问题 更多 >
编程相关推荐