python - 如何在beatifulsoup中的标签前添加空格
问题描述
我有以下代码:
html = urlopen(req).read()
soup = BeautifulSoup(html, "lxml")
# remove all script and style elements
for script in soup(["script", "style"]):
script.extract()
# get text
text = soup.get_text()
问题是,如果在我的 html 页面中有类似的内容
Oxford<br />Laboratory
,并且在删除样式后,我得到OxfordLaboratory
所以这是我的问题:我怎样才能在所有之前添加一个空格,<
这样单词就不会组合在一起?
解决方案
推荐阅读
- mysql - SQL 选择表,其中包含多对多关系中的多个属性
- salesforce - 如何使用 REST 或 SOAP API 从 Salesforce 营销云获取 SMS 交付每日报告
- php - 使用 laravel 导出 Excel 中的问题
- azure - 在 adf 逻辑应用程序中使用有效负载运行时逻辑应用程序引发扩展 ajax 错误
- c# - 是否可以覆盖 DateTime.Now 或警告开发人员不要使用它?
- vb.net - 多选行失败时捕获 Datagridview 错误
- sql-server - 如何判断当前会话是否持有锁?
- mysql - 将列作为日期类型从 CSV 导入 MySQL
- handlebars.js - 如何将自定义链接数据添加到 Branch.io 中的自定义 Deepview?
- node.js - 在浏览器中显示基线 h264 帧流