【发布时间】:2011-02-07 19:05:55
【问题描述】:
给定
<a href="www.example.com/"></a>
<table class="theclass">
<tr><td>
<a href="www.example.com/two">two</a>
</td></tr>
<tr><td>
<a href ="www.example.com/three">three</a>
<span>blabla<span>
</td></td>
</table>
我怎样才能只抓取表 class="the class" 中的内容?我尝试使用
soup = util.mysoupopen(theexample)
infoText = soup.findAll("table", {"class": "the class"})
但我不知道如何进一步定义发现语句。我尝试过的其他方法是将 findAll() 的结果转换为数组。然后寻找针何时出现的模式,但我找不到一致的模式。 谢谢
【问题讨论】:
-
你想废弃什么?你说“我怎样才能只刮掉表 class="the class" 里面的那个?”你指的是链接吗?
标签: python html beautifulsoup