beautifulsoup - 删除 beautifulSoup 输出中 {} 括号之间的所有内容
问题描述
我想解析文本表单 html 页面。一些页面返回文本,但也有一些{}
我不想要的文本和字符。
我试过了:
import re
from bs4 import BeautifulSoup
art = soup.find_all('p')
for clean in art:
x = clean.text.encode('ascii', 'ignore').decode('ascii')
x = re.sub("([{]).*?([}])", "\g<1>\g<2>", x)
print(x.strip())
但是没有雪茄...
解决方案
推荐阅读
- java - Java:如何将 0 到 1 之间的值四舍五入到至少 3 位小数?
- c# - 我在 Visual Studio 2013 的可扩展性选项卡中找不到添加自定义命令选项
- linux - CMake/CPack:将二进制文件从 Linux 部署到 Mac OSX
- asp.net-core - 基于策略的授权,仅允许作为资源所有者的用户能够查看/编辑
- python - 访问类外的类方法变量
- azure-devops - 如何在 azure DevOps YAML 管道中发送构建后消息?
- angular - 如何在ng中为每3个元素添加行和列
- r - blogdown hugo 删除社交链接
- php - Laravel 419 点击登录后过期
- ios - 如何用变量的内容命名结构的实例 - Swift