简体   繁体   English

jsoup中element.children的替代

[英]Alternative of element.children in jsoup

Alright I am having trouble with finding an equivalent of Element.children() because I have an Elements object... What I am trying to do is download an html file (well I have done that...) and identify a single table row (, I've done that by using doc.getElementsByClass("emphasizedRowColor"); because the row I want has that emphasizedRowColor class and no other elements do). 好吧,我在寻找等效的Element.children()时遇到了麻烦,因为我有一个Elements对象...我想做的是下载一个html文件(我已经做到了...)并标识一个表row(我已经通过使用doc.getElementsByClass(“ emphasizedRowColor”)来做到这一点;因为我要的行具有了强调的RowColor类,而其他元素则没有)。 I just don't understand how to isolate the one Element in my Elements object RWTableRow. 我只是不了解如何在我的Elements对象RWTableRow中隔离一个Element。 Html: HTML:

<tr class="rwOdd emphasizedRowColor">
<td class="jewel" style="">
<div class="teamJewel" style="background-position: 0px -336px;margin: 0 0 2px 2px;"></div>
</td>
<td class="left" style=""> Detroit</td>
<td style="">18</td>
<td style="">9</td>
<td style="">5</td>
<td style="">4</td>
<td class="narrowStatsColumn cSrt" style="">22</td>
<td class="narrowStatsColumn" style="">9</td>
<td style="">45</td>
<td style="">48</td>
<td style="">3-2-4</td>
<td style="">6-3-0</td>
<td style="">3-3-4</td>
</tr>

I can figure out what to do once I actually get the table as an Element but oh boy I think I just need a fresh set of eyes to figure out what I'm doing... 一旦我将表格实际作为元素,我就可以弄清楚该怎么做,但是,天哪,我想我只需要换一个新的眼睛即可弄清楚我在做什么。

Java: Java的:

Document doc = Jsoup.connect(url).userAgent("Mozilla").get(); 
Elements RWTableRow = doc.getElementsByClass("emphasizedRowColor");

As you can see, I'm in quite the pickle... 如您所见,我很腌...

Elements is a standard java.util.List , you can simply call Elements是标准的java.util.List ,您可以简单地调用

 Element e = RWTableRow.get(0);

And there you have it. 那里有它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM