【发布时间】:2017-07-21 14:41:23
【问题描述】:
我试图在这些列中获取单元格值,但我只在 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
虽然,我希望这两列中存在值。
【问题讨论】:
-
你能粘贴
response的(相关部分)吗?
标签: python html web-scraping beautifulsoup lxml