python - BeautifulSoup 在特定标题后得到表格

标签 python beautifulsoup

我如何定位 BS4 以在 <h3>64-bit deb for Ubuntu/Debian</h3> 之后的表格开始? ?有很多表,唯一不同的是表头。

<h3>Windows 64-bit</h3>
<table width="600" border="1" align="center">
:
</table>
:
<h3>64-bit deb for Ubuntu/Debian</h3>
<table width="600" border="1" align="center">
:
</table>
:

最佳答案

这行得通吗?

>>> for header in soup.find_all('h3'):
...     if header.get_text() == '64-bit deb for Ubuntu/Debian':
...         header.find_next_sibling()
...
<table align="center" border="1" width="600">
:
</table>

关于python - BeautifulSoup 在特定标题后得到表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57655108/

相关文章:

python - 自动解析消歧页面

python - findAll-beautifulsoup-python 无法正常工作

python - 如何将 GEKKO 中的值转换为 float

python - 给定置换数组,找到置换

Python从函数调用中的args的嵌套字典中提取值

python - 为什么我不能循环遍历 `payload` 中的 `requests` 来迭代我的网络抓取?

python - BeautifulSoup 不限制Python的结果

python - F.relu(X) 和 torch.max(X, 0) 之间的区别

python - 如何降低 seaborn 中 x-ticks 的密度

python - 无法使用 python 和 beautifulsoup 抓取网页中的某些 href