解析表格
58.4 解析表格
网页表格常用 table/tr/td 结构,可逐行提取。
读取表格行
from bs4 import BeautifulSoup
html = '<table><tr><td>语文</td><td>90</td></tr></table>'
soup = BeautifulSoup(html, 'html.parser')
for tr in soup.find_all('tr'):
print([td.text for td in tr.find_all('td')])