【发布时间】:2014-07-11 21:30:47
【问题描述】:
<th rowspan="3" style="background:#c0cfe4; width:7em">present</th>
<td>ich <a href="/wiki/mache" title="mache">mache</a></td>
<td>wir <strong class="selflink">machen</strong></td>
<th rowspan="3" style="background:#c0cfe4; width:7em">i</th>
<td>ich <a href="/wiki/mache" title="mache">mache</a></td>
<td>wir <strong class="selflink">machen</strong></td>
</tr>
<tr>
<td>du <a href="/wiki/machst" title="machst">machst</a></td>
<td>ihr <a href="/wiki/macht" title="macht">macht</a></td>
<td>du <a href="/wiki/machest" title="machest">machest</a></td>
<td>ihr <a href="/wiki/machet" title="machet">machet</a></td>
</tr>
<th colspan="6" style="background:#9999DF">future i</th>
</tr>
<tr>
<th rowspan="3" style="background:#ccccff">infinitive</th>
<td rowspan="3" colspan="2">machen werden</td>
<th rowspan="3" style="background:#ccccff">subjunctive i</th>
<td>ich werde machen</td>
<td>wir werden machen</td>
</tr>
<tr>
<td>du werdest machen</td>
<td>ihr werdet machen</td>
</tr>
<tr>
<td>er werde machen</td>
<td>sie werden machen</td>
</tr>
我试图在第 9 行提取 <td>du <a href="/wiki/machst" title="machst">machst</a></td>。当我使用 soup.find_all("td" text="re.compile("^du)) 执行搜索时,我得到的只是第 24 行的标签。这样做的正确方法是什么?
【问题讨论】:
-
我认为这不会影响问题,但我注意到第 7 行上的第一个
</tr>结束标记缺少相应的<tr>开始标记。我假设您只是在创建问题时错过了复制标签。
标签: python html html-parsing beautifulsoup