首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >漂亮汤findAll()结果上的findall()返回TypeError

漂亮汤findAll()结果上的findall()返回TypeError
EN

Stack Overflow用户
提问于 2010-10-15 00:09:56
回答 1查看 13.2K关注 0票数 2

嗨,我对Python和Beautiful soup都是新手。我试图仅从表格的特定部分获取文本。但是似乎findAll的结果不是可以再次运行findAll的BeautifulSoup类型。

代码语言:javascript
复制
select = soup.find('table',{'id':"tp_section_1"})
print "got the right table"
tissues = select.findAll('td',{"class":re.compile("tissue[10]")})
print "got the right cells, now I'd like to get just the text"
tissueText = tissues.findAll(text = True)

最后一行错误,带有一个TypeError。我似乎能够对查找结果运行findAll,但不能对后续结果运行findAll。是不是因为我需要做这个元素方面的工作?

作为参考,在最后一行之前,组织的内容看起来像这样,我试图提取文本,比如“肾上腺”:

<td valign="top" height="15" class="tissue1" nowrap> <a class="tissue_link" href="normal_unit.php?antibody_id=20769&amp;mainannotation_id=2065466">Adrenal gland</a> </td>

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2010-10-15 00:19:55

是的,你需要按元素来做。find返回单个元素。findAll返回一个列表,即使该列表只包含一项。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3935224

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档