【发布时间】:2014-02-15 17:18:29
【问题描述】:
我的标记为:
<p>Sample text. Click <a href="google.com">Here</a></p>
我想用<span> 替换<p> 标记而不更改标记的子项或文本
【问题讨论】:
标签: python html beautifulsoup
我的标记为:
<p>Sample text. Click <a href="google.com">Here</a></p>
我想用<span> 替换<p> 标记而不更改标记的子项或文本
【问题讨论】:
标签: python html beautifulsoup
您的任务可以使用replaceWith 完成。您必须复制要用作替换的元素,然后将其作为参数提供给replaceWith。 documentation for replaceWith 非常清楚如何做到这一点。
无论如何你都可以阅读这个问题How to change tag name with BeautifulSoup?
【讨论】: