html - discory.py BeautifulSoup 在许多 div 类后面得到一个类
问题描述
我有以下html代码:
<div class="one">
<div class="two">
<div class="three">
<a class="three" href="link">My link</a>
</div>
</div>
</div>
我怎样才能得到href链接?
解决方案
这将为您提供 html 页面中的所有链接。
soup = BeautifulSoup(html)
for a in soup.find_all('a', href=True):
print(f"Found the URL:{a['href']}")
推荐阅读
- android - 保存文件显示 Permission Denied 虽然已授予权限
- javascript - 如何在滚动时修复导航栏中的按钮
- swift - Xcode Swift 语言版本,未指定和版本之间的不同?
- python-3.x - 阿里巴巴 odps 连接中 writer.write(xlist) 时出现 ReadTimeOut 错误。有什么建议吗?
- php - 自定义 BuddyPress 注册表单模板,而不仅仅是 registar.php
- python - 窗口不同区域的 Tkinter 键绑定
- css - 无法从 EJS 中的 CSS 加载本地图像
- php - wordpress中的文件写入问题
- r - R中数据框行中的子集
- java - 常量池中的无效字节标记:19 错误消息