【发布时间】:2017-06-30 06:08:50
【问题描述】:
这是示例 HTML 代码:
<div class="cb-col cb-col-25 cb-mtch-blk"><a class="cb-font-12" href="/live-cricket-scores/16947/ind-vs-ban-only-test-bangladesh-tour-of-india-2017" target="_self" title="India v Bangladesh - Only Test">
<div class="cb-hmscg-bat-txt cb-ovr-flo ">
<div class="cb-ovr-flo cb-hmscg-tm-nm">BAN</div>
<div class="cb-ovr-flo" style="display:inline-block; width:140px">322/6 (104.0 Ovs)</div>
</div>
我想从上面解析的 html 中提取像 BAN 和 322/6 (104.0 Ovs) 这样的文本。我就是这样-
soup = BeautifulSoup(html)
div_class = soup.findAll('div',class_='cb-col cb-col-25 cb-mtch-blk')
for each in div_class:
#I want to get those texts from variable 'each'
我该怎么做?
【问题讨论】:
标签: python python-3.x beautifulsoup