【发布时间】:2020-05-26 16:32:52
【问题描述】:
我正在为一个 DS 项目进行网络抓取,为此我正在使用 BeautifulSoup。但我无法从“table”类中的“tbody”标签中提取 Duration。 以下是 HTML 代码:
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th>Start Date</th>
<th>Duration</th>
<th>Stipend</th>
<th>Posted On</th>
<th>Apply By</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div id="start-date-first">Immediately</div>
</td>
<td>1 Month</td>
<td class="stipend_container_table_cell"> <i class="fa fa-inr"></i>
1500 /month
</td>
<td>26 May'20</td>
<td>23 Jun'20</td>
</tr>
</tbody>
</table>
</div>
注意:为了提取“立即”文本,我使用以下代码:
x = container.find("div", {"class" : "table-responsive"})
x.table.tbody.tr.td.div.text
【问题讨论】:
标签: python html web-scraping beautifulsoup