用java中的JSoup解析没有ID的html表

用java中的JSoup解析没有ID的html表,java,html,parsing,jsoup,Java,Html,Parsing,Jsoup,我正在为一个研究项目处理大量数据。我的计算机上有许多html文件,我需要将一些信息读入java程序 我使用Jsoup加载文档 不幸的是,html中的表没有类或id(并且有多个表)。我已经搜索了堆栈,但找到的所有答案都使用table.class 我如何从下表中获得数据(2014年1月18日)?doc.select现在不工作了,因为我认为缺少类 I am trying something like this: Element table = doc.select("table").firs

我正在为一个研究项目处理大量数据。我的计算机上有许多html文件,我需要将一些信息读入java程序

我使用Jsoup加载文档

不幸的是,html中的表没有类或id(并且有多个表)。我已经搜索了堆栈,但找到的所有答案都使用table.class

我如何从下表中获得数据(2014年1月18日)?doc.select现在不工作了,因为我认为缺少类

I am trying something like this:

    Element table = doc.select("table").first();

            Iterator<Element> ite = table.select("td").iterator();

            ite.next(); 

            System.out.println("Value 1: " + ite.next().text());
            System.out.println("Value 2: " + ite.next().text());
            System.out.println("Value 3: " + ite.next().text());
            System.out.println("Value 4: " + ite.next().text());




<table border=0 cellpadding=0 cellspacing=0 width=650 height=18><tr><td class="header" style="color:#FFFFFF;"><table border=0 cellpadding=0 cellspacing=0><tr>
<td><img src="/images/title_ultratop.png"></td><td style="color:#FFFFFF;vertical-align:middle;"><b>50 DANCE<br> 
<a href="link"><img src="/images/arr_bw.png" border=0 style="margin-bottom:1px;margin-right:3px;"></a>18/01/2014
</b></td></tr></table>

我想我现在正在展示一整张桌子。如何获得第二个元素

对,第三个嵌入式表,它可以工作

元素表=单据选择(“表格”).first()


仍然需要在站点上选择不同的表。我读到了关于table:contains(word)的内容。希望那会是个好消息

您的html中存在一些问题。我想正确的答案是:

<table border="1" cellpadding="0" cellspacing="0" width="650" height="18">
    <tr>
        <td class="header" style="color:#FFFFFF;">
            <table border="1" cellpadding="0" cellspacing="0">
                <tr>
                    <td><img src="/images/title_ultratop.png"></td>
                    <td style="color:#FFFFFF;vertical-align:middle;">
                        <b>50 DANCE
                        <br>
                        <a href="link"><img src="/images/arr_bw.png" border="0"
                                            style="margin-bottom:1px;margin-right:3px;"></a>
                        18/01/2014
                        </b>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<table border="1" cellpadding="0" cellspacing="0" width="650" height="18">
    <tr>
        <td class="header" style="color:#FFFFFF;">
            <table border="1" cellpadding="0" cellspacing="0">
                <tr>
                    <td><img src="/images/title_ultratop.png"></td>
                    <td style="color:#FFFFFF;vertical-align:middle;">
                        <b>50 DANCE
                        <br>
                        <a href="link"><img src="/images/arr_bw.png" border="0"
                                            style="margin-bottom:1px;margin-right:3px;"></a>
                        18/01/2014
                        </b>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
    Elements td = doc.select("table table td b");
    TextNode el = (TextNode)td.first().childNode(4);
    System.out.println(el.text());