python - 如何使用python去除开始和结束标签 美丽的汤
问题描述
我很难从 json url 中剥离开始和结束标签。我用过漂亮的汤,我面临的唯一问题是<pre>
我的回复中有标签。请告知我如何删除开始和结束标签。我正在使用的代码块在这里:
page = Page( "link to json")
soup = bs.BeautifulSoup(page.html, "html.parser")
#fetching the response i want from the url it's inside pre tags.
json = soup.find("pre")
print(json)
解决方案
所以感谢德米安狼。解决方案是这样的:
page = Page( "link to json")
soup = bs.BeautifulSoup(page.html, "html.parser")
#fetching the response i want from the url it's inside pre tags.
json = soup.find("pre")
print(json.text)
推荐阅读
- github - 如果每次编辑标记都更改,我如何从 MicroStrategy 获取原始 GitHub 内容?
- r - 重新安装 R / Rstudio 和迁移库
- android - 如何在夜间模式下使 MPandroidchart 饼图中的颜色变暗?
- mysql - 选择 后的十进制数。大于 0
- scala - 连接后是否有只选择一个数据框列的简写?
- c# - 单元测试:尽管 Returns() 设置为 true,但模拟服务返回默认布尔值 (false)。C# xunit 最小起订量
- powershell - 当用户使用 ADSI 脚本时防止权限提升
- github-actions - 如何在 PR 评论编辑上运行 GitHub Action?
- html - ngClass 有没有更好的方法让样式始终存在并根据条件添加其他样式
- javascript - Wix - 如何远程登录外部站点