web-scraping - 无法从 url 中选择表
问题描述
我无法从指定的 URL 中选择一个表(或实际上任何东西)。我用find_all
了方法无济于事。网页上有多个由<h3>
标签分隔的表格(下图是带有<h3>
“基本”标签的表格)。
import requests
from bs4 import BeautifulSoup
res = requests.get('Example_URL')
soup = BeautifulSoup(res.text,'html.parser')
table = soup.find_all('table')[0]
print(table)
我希望能够选择表格,然后将内容打印到控制台上。但print(table)
回报IndexError: list index out of range
。
解决方案
推荐阅读
- python - Python 中的 WHILE 和 IF 组合
- excel - 跳过循环中的空白行
- python - 将元素映射到百分位数的最快方法?现在使用 pandas 但想知道是否有更快的方法
- java - IllegalArgumentException PID:3701
- pandas - 是否可以结合两个线性回归模型(相同的结构,不同的数据)?
- mysql - MYSQL 和 Hibernate:使用默认值 0 而不是“null”插入
- python - 如何在 Python 中生成 Azure blob SAS URL?
- python - 通过从旧数据框中附加行来创建新数据框
- sqlite - SQLITE - 结合一对夫妇的名字(包括名字和姓氏)
- javascript - 如何使用无密码魔术链接登录到 iOS 主屏幕书签 web 应用程序:通用链接?