【发布时间】:2018-03-13 02:26:18
【问题描述】:
我最近开始使用 Jsoup 库,但在访问类和打印已解析代码时遇到了一些问题。我想打印出球队名称(“NYE”)和获胜次数(14),我尝试了多种方法来执行这个问题,包括使用 getElementsByClass、getElementsByTag、select 和其他一些方法,但还没有任何产生输出的运气。任何帮助将不胜感激。
<div class="table-responsive">
<table class="table table-striped table-condensed u-verticalPadding--x-small ScrollArea-content">
<thead>
<tr>
<th/>
<th class="Standings-header-team"/>
<th class="Standings-header" title="Division">DIV</th>
<th class="Standings-header" title="Matches Played">MP</th>
<th class="Standings-header" title="Match Wins">W</th>
<th class="Standings-header" title="Match Losses">L</th>
<th class="Standings-header" title="Maps Won, Lost, Tied">Map W-L-T</th>
<th class="Standings-header" title="Map Differential">DIFF</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<b>1</b>
</td>
<td class="Standings-details-team">
<div class="IconLabel">
<span class="IconLabel-item">
<img src="https://bnetcmsus-a.akamaihd.net/cms/page_media/3PBR8VEYM8SH1517250447953.svg" alt="New York Excelsior" class="Icon">
</span>
<span class="IconLabel-item hidden-xs">
<div>New York Excelsior</div>
</span>
<span class="IconLabel-item hidden-sm hidden-md hidden-lg hidden-xl" title="New York Excelsior">
<div>NYE</div>
</span>
</div>
</td>
<td class="Standings-details-division">ATL</td>
<td class="Standings-details">16</td>
<td class="Standings-details">14</td>
<td class="Standings-details">2</td>
<td class="Standings-details">51-15-2</td>
<td class="Standings-details is-positive">+36</td>
</tr>
【问题讨论】:
-
让我们从描述您如何知道要提取哪些数据开始?你如何识别/找到它?
-
@Pshemo 我知道我需要团队名称和记录,我将把输出导入到 Excel 表中,然后在我的 Java Web 应用程序中使用该表。我看到像 IconLabel-Item 这样的跨度类存储了团队名称等信息,但我还没有抓取该跨度的属性来获取字符串。