我需要从表格http://www.mercado.ren.pt/EN/Electr/MarketInfo/Interconnections/CapForecast/Pages/Daily.aspx
获取数据(实际 - 灰色和预测容量 - 绿色)我正在使用Jsoup,我不知道如何根据颜色获得容量。最糟糕的是我甚至无法在XML中找到颜色。
HTML代码如下所示:
<table class="gridALL" cellspacing="0" cellpadding="2" border="0">
<tr>
<th align="left" colspan="2">
<A id='helpTimePeriod' href='/EN/pages/TimePeriods.aspx' target='_blank'>
<span class='txtDATA'>HOURS</span>
<span style='vertical-align: 13%;' class='icon-info'> </span>
</A>
</th>
<th align="left" valign="middle" colspan="29">Import Capacity</th>
</tr>
<tr class="tabHEADER">
<th class="rbcellBDRCOLOR" align="right" scope="col">HOUR</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">26 May</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">27 May</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">28 May</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">29 May</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">30 May</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">31 May</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">01 Jun</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">02 Jun</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">03 Jun</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">04 Jun</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">05 Jun</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">06 Jun</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">07 Jun</th>
<th class="rbcellBDRCOLOR" align="right" scope="col">08 Jun</th>
<th class="bcellBDRCOLOR" align="right" scope="col">09 Jun</th>
</tr>
<tr class="trPAR">
<td class="rcellBDRCOLOR" align="right" width="50">1</td>
<td class="txtrVERIF" align="right" width="60">2700</td>
<td class="txtrPREV" align="right" width="60">2700</td>
<td class="txtrPREV" align="right" width="60">2700</td>
<td class="txtrPREV" align="right" width="60">2700</td>
<td class="txtrPREV" align="right" width="60">2700</td>
<td class="txtrPREV" align="right" width="60">2700</td>
<td class="txtrPREV" align="right" width="60">2700</td>
<td class="txtrPREV" align="right" width="60">2700</td>
<td class="txtrPREV" align="right" width="60">2400</td>
<td class="txtrPREV" align="right" width="60">2400</td>
<td class="txtrPREV" align="right" width="60">2400</td>
<td class="txtrPREV" align="right" width="60">2400</td>
<td class="txtrPREV" align="right" width="60">2400</td>
<td class="txtrPREV" align="right" width="60">2400</td>
<td class="txtPREV" align="right" width="60">2400</td>
</tr>
是否可以使用Jsoup lib获取此字段?
编辑:
到目前为止,我有这个,现在:
doc = Jsoup.connect(path).get();
for (Element table: doc.select("table.gridALL")) {
for (Element row: table.select("tr")) {
Elements tds = row.select("td");
if (tds.size() >= 16) {
String record = tds.get(column).text();
String recordColor = tds.get(column).attr("class");
我只能获得属性(txtrVERIF / txtrPREV)或容量。如何根据属性获取容量?我应该给出什么条件?