目前我的代码执行如下操作:
soup = BeautifulSoup(value)
for tag in soup.findAll(True):
if tag.name not in VALID_TAGS:
tag.extract()
soup.renderContents()
Run Code Online (Sandbox Code Playgroud)
除了我不想丢弃无效标签内的内容.如何在删除标签但在调用soup.renderContents()时保留内容?