【发布时间】:2020-05-20 20:26:13
【问题描述】:
我正在尝试从网页中的表格中提取多个单元格,并最终将结果导出到 Excel。
这些单元格位于 id 为“fila_88”的 tbody 中。
每行都包含在一个标签内。
每个单元格都包含在一个标签内。
我在python中有以下代码:
sopa = BeautifulSoup(browser.page_source, 'html.parser') # Creates BS element
tabela = sopa.find_all('tbody', id = "fila_88") # Extracts table from source, this works
linha = tabela.find_all('tr') # This line fails
我得到的错误是:
"ResultSet object has no attribute '%s'. You're probably treating a list of elements like a single element. Did you call find_all() when you meant to call find()?" % key
我的源代码如下:https://pastebin.com/raw/P2aTsXnw
谁能解释我做错了什么?
编辑:为清楚起见,这是提取的表格:https://pastebin.com/raw/sGTYPvaD
【问题讨论】:
-
您从该错误消息中了解/不了解什么?对我来说,这似乎内容丰富且直截了当。
标签: python selenium web-scraping html-table beautifulsoup