我想从一行中获取数据,其中包含更多数据,以空格与网站分隔,然后如何将此数据提取到excel并使用selenium webdriver将其转换为列?
我的代码:
WebElement Table = driver.findElement(By.xpath(".//*[@id='schemeGridHolder']/div/div[6]/div/table"));
List<WebElement> rows = Table.findElements(By.tagName("tr"));
Iterator<WebElement> i = rows.iterator();
int x=0;
while(i.hasNext())
{
WebElement row = i.next();
List<WebElement> columns = row.findElements(By.tagName("td"));
Iterator<WebElement> j = columns.iterator();
int y=1;
while(j.hasNext())
{
WebElement column = j.next();
System.out.println(column.getText());
Row dataRow = sheet23.createRow((short)x);
System.out.println("x="+""+x);
System.out.println("y="+""+y);
Cell cell12 = dataRow.createCell(y);
cell12.setCellType(Cell.CELL_TYPE_STRING);
cell12.setCellValue(column.getText());
y=y+1;
}
x=x+1;
}
HTMLCode:
<table>
<tr>
<td colspan="100">
<div>Name</div>
<div class="clearfix scheme-name">
<a id="name-2019-7993063096" class="" target="new">
Alice Lopez
</a>
</div>
<div class="clearfix header-resp">
Id no
</div>
<div id="sch-inv-2019-7993063096" class="clearfix scheme-mtm" data-v-min="-999999999.99" data-d-group="2">
AS4567H
</div>
</td>
</tr>
<tr>
<td colspan="100">
<div>Name</div>
<div class="clearfix scheme-name">
<a id="name-2019-7993063096" class="" target="new">
John Stark
</a>
</div>
<div class="clearfix header-resp">
Id no
</div>
<div id="sch-inv-2019-7993063096" class="clearfix scheme-mtm" data-v-min="-999999999.99" data-d-group="2">
B8765M
</div>
</td>
</tr>
</table>
但是在excel中它显示单行中的所有数据,因为在该特定网站中数据也是单行,由div标签分隔,当我打开我的Excel时,它也显示单行中的所有数据。例如, ExcelFile
从那个excel我想删除Id no .....我该怎么办?