使用Selenium na python从HTML中提取第二个表
我使用Selenium和python从HTML中提取表,但我只能提取第一个表。我想提取第二个表也我是新的t硒 Html代码使用Selenium na python从HTML中提取第二个表,python,selenium,selenium-webdriver,Python,Selenium,Selenium Webdriver,我使用Selenium和python从HTML中提取表,但我只能提取第一个表。我想提取第二个表也我是新的t硒 Html代码 <div class="fondo-top"> <h3>Flood Forecasted Site</h3> <div class="editorwys"> <h4>Site Name : Araria</h4> &
<div class="fondo-top">
<h3>Flood Forecasted Site</h3>
<div class="editorwys">
<h4>Site Name : Araria</h4>
<table style="width: 100%">
<tbody><tr>
<th style="width: 25%"><strong>District Name:</strong></th>
<td style="width: 25%"><strong>Araria</strong></td>
<th style="width: 25%"><strong>Warning Level (WL):</strong></th>
<td style="width: 25%"><strong> Meters (m)</strong></td>
</tr>
<tr>
<th><strong>River Name:</strong></th>
<td><strong>Mahananda</strong></td>
<th><strong>Danger Level (DL):</strong></th>
<td><strong> Meters (m)</strong></td>
</tr>
<tr>
<th><strong>Basin Name:</strong></th>
<td><strong>GANGA<strong></strong></strong></td>
<th><strong>Highest Flood Level (HFL):</strong></th>
<td><strong>49.4 Meters (m)<strong></strong></strong></td>
</tr>
<tr>
<th><strong>Division Name:</strong></th>
<td><a target="_blank" href="/opencms/opencms/ffs/Detail?code=029-mgd4ptn " onclick="window.open(this.href, this.target, 'width=1000, height=600, toolbar=no, resizable=no'); return false;">Lower Ganga Division-I(LGD-I), Patna</a></td>
<th><strong>HFL Attained date:</strong></th>
<td>14-08-2017</td>
</tr>
</tbody></table>
<p> </p>
<table>
<tbody><tr>
<th colspan="3" style="text-align: center;"><strong>PRESENT WATER LEVEL</strong></th>
</tr>
<tr>
<td class="" style="width:33%; height:18px;">Date: 22-06-2018 08:00</td>
<td class="" style="width:33%;">Value: 45.34 Meters (m)</td>
<td class="" style="width:33%;">Trend: Steady</td>
</tr>
<tr>
<th colspan="3" style="text-align: center;"><strong>CUMULATIVE DAILY RAINFALL</strong></th>
</tr>
<tr>
<td style="width:33%; height:18px;">Date: 22-06-2018 08:30</td>
<td style="width:33%;">Value: 5.0 Milimiters (mm)</td>
<td style="width:33%;"></td>
</tr>
</tbody></table>
<p> </p>
<table style="width: 100%">
<tbody><tr>
<th colspan="4" style="text-align: center;"><strong>NO FLOOD FORECAST</strong></th>
</tr>
</tbody></table>
<div class="botonera">
<a href="/ffs/data-flow-list-based/" class="mas-info"> Go Back</a>
</div>
</div>
</div>
洪水预报点
网站名称:Araria
地区名称:
阿拉里亚
警告级别(WL):
米(米)
河流名称:
Mahananda
危险等级(DL):
米(米)
盆地名称:
恒河
最高洪水位(HFL):
49.4米(米)
部门名称:
HFL到达日期:
14-08-2017
当前水位
日期:2018年6月22日08:00
数值:45.34米(米)
趋势:稳定
累积日降雨量
日期:2018年6月22日08:30
数值:5.0毫米
无洪水预报
我正在使用驱动程序。通过css\u选择器(“table>tbody”)查找元素。text
提取第一个表。现在如何提取第二个和第三个表???我将非常感谢您在这方面提供的任何帮助您可以使用这些方法查找多个元素(这些方法将返回一个列表)并创建所有表,而不是使用一个元素find\u element\u by\u css\u selector
,请尝试以下操作
for form_body in driver.find_elements_by_css_selector('table > tbody'):
print(form_body.text)