📜  bs4 表格示例 python 代码示例

📅  最后修改于: 2022-03-11 14:46:17.926000             🧑  作者: Mango

代码示例1
data = []
table = soup.find('table', attrs={'class':'lineItemsTable'})
table_body = table.find('tbody')

rows = table_body.find_all('tr')
for row in rows:
    cols = row.find_all('td')
    cols = [ele.text.strip() for ele in cols]
    data.append([ele for ele in cols if ele]) # Get rid of empty values