【发布时间】:2020-01-18 23:39:18
【问题描述】:
我有以下 HTML 部分,需要用 BeautifulSoup 提取 2.56% 的值。
<div class="box boxRatio">
<h2 class="sectHed">Dividend Yield Range, Past 5 Years</h2>
<table class="rangeModTable">
<tr>
<td class="col1">Minimum</td>
<td class="col2">
1.82%
</td>
<td class="col3">Jan 26 2018</td>
</tr>
<tr>
<td class="col1">Maximum</td>
<td class="col2">
3.77%
</td>
<td class="col3">Oct 08 2019</td>
</tr>
<tr>
<td class="col1">Average</td>
<td class="col2">
2.56%
</td>
<td class="col3"></td>
</tr>
</table>
</div>
我正在使用
divyield_box = soup.find(".boxRatio > .col2:nth-of-type(2)")
我不断收到 AttributeError: 'NoneType' object has no attribute 'text'
【问题讨论】:
标签: python web-scraping beautifulsoup