使用漂亮汤从html获取列值

我试图获取这些列中的单元格的值,但我只能获取html表中这些列的标题。

soup = BeautifulSoup(response, 'lxml')

table = soup.find('table', {'class', 'annotation'})
for row in table.findAll("tr"):
    cells = row.findAll("td")
    if len(cells) == 21:
        gene_id = cells[4].text
        gene_aspect = cells[6].text
        print(gene_id, gene_aspect)

我得到了这个输出

GO Identifier



Aspect

不过,我想要这两列中的值。

转载请注明出处:http://www.bqysc.com/article/20230526/1964092.html