从下面的成绩表中提取所有学生的信息。
1. 使用 find('table') 找到表格
2. 使用 find_all('tr') 获取所有行
3. 对每一行使用 find_all('td') 获取单元格数据
table = soup.find('table', class_='score-table')
rows = table.find_all('tr')[1:] # 跳过表头
for row in rows:
cells = row.find_all('td')
name = cells[0].text
chinese = cells[1].text
# ...
| 姓名 | 语文 | 数学 | 英语 |
|---|---|---|---|
| 小明 | 95 | 88 | 92 |
| 小红 | 87 | 95 | 89 |
| 小刚 | 92 | 90 | 85 |
| 小丽 | 88 | 92 | 94 |
| 小华 | 90 | 87 | 91 |
应该提取到 5 名学生的成绩数据
例如:{'name': '小明', 'chinese': 95, 'math': 88, 'english': 92}