【发布时间】:2015-09-14 15:17:44
【问题描述】:
我正在从没有所有标签的 html 页面中提取文本(使用 Python 和 BeautifulSoup)。但是,标签不会替换为空白。因此,例如,对于“blah blahDIVTAGblah”,我得到以下文本“blah blahblah”。如何在第二个和第三个 blah 之间插入空白?我正在使用以下代码。
# kill all script and style elements
for script in soup(["script", "style"]):
script.extract()
【问题讨论】:
标签: python beautifulsoup