python - 查找表格内的所有链接

标签 python beautifulsoup

我的 html 页面有:

...
<table class="t1" ..>
<tr><td> ... <a href="">...</a> ... <a href="">..</a>
</table>

...

我有:

html = BeautifulSoup(page)

links = html.findAll('a', ?????????)

如何找到该表中的所有链接?

最佳答案

找到表格(在本例中为 by class),然后找到其中的所有链接。

html = BeautifulSoup(page)
table = html.find('table', 't1')
links = table.findAll('a')

关于python - 查找表格内的所有链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4940885/

相关文章:

python - Ubuntu 中的 header 、用户代理、Url 请求

python - 获取指向包含某些文本的标签的xpath

python - 如何在 VScode 中重构文件/python 模块?

python - 在数据框中添加字典作为新行

python - 在网格中生成随机 X,Y 坐标

python - 在 BeautifulSoup 中正确获取 href 标签

python - 在 python 中使用 urllib 时双引号和单引号字符串之间的不同行为

Python 正则表达式 : find and replace commas between quotation marks

python - 删除某个版本的 python 包

python - BeautifulSoup "find"行为不一致 (bs4)