【发布时间】:2018-04-26 22:42:19
【问题描述】:
我正在使用 Beautiful Soup 替换文本。
这是我的代码示例:
for x in soup.find('body').find_all(string=True):
fix_str = re.sub(...)
x.replace_with(fix_str)
如何跳过script 和comment (<--! -->) 标签?
如何确定x 中有哪些元素或标签?
【问题讨论】:
-
您在使用 BeautifulSoup 4 吗?参考stackoverflow.com/questions/33138937/…
-
是的,我用的是 bs4,谢谢
标签: python beautifulsoup