本文介绍了如何使用Jsoup获取重复号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <p class="tl f12">2015-12-06 18:19:42 由<span class="co4">咕咚</span>上传
  <span style="display:none;  margin-top: 5px" class="fr marr15 mc_tips" id="mc_tips_dd5e7f6e-9c02-11e5-a3c1-015176cddf29"><img src="http://static.codoon.com/image/mc/18.gif"></span></p>
            <table cellpadding="0" cellspacing="0" class="f12 co6" route_id="dd5e7f6e-9c02-11e5-a3c1-015176cddf29"  id="dd5e7f6e-9c02-11e5-a3c1-015176cddf29" >
                <tr>
                    <td width="70" height="42" class="tc">
                        <div class="m_tc" style="width:32px; height:32px;">
                            <img src="http://static.codoon.com/image/app_icon/walk.png" />
                        </div>
                    </td>
                    <td width="100" height="42">
                        <span>距离</span><br /><span class="f18 co14 fb f24">0.22</span><span class="f12">公里</span>
                    </td>
                    <td width="100" height="42">
                        <span>运动时长</span><br /><span class="f18 co14 fb f24">00:03</span>
                    </td>
                    <td width="120" height="42">
                        <span>平均速度</span><br /><span class="f18 co14 fb f24">3.5</span><span class="f12">公里/小时</span>
                    </td>
                    <td  width="110">
                        <span>燃烧</span><br /><span class="f18 co14 fb f24">14.9</span>大卡
                    </td>
                    <td  class="tl" >

                    </td>
                </tr>
            </table>

我得到了一些这样的数据,我想在class ="f18 co14 fb f24"中获得数据所以我将Jsoup用作

i got some data like this,and i want to get data in class="f18 co14 fb f24"so i use Jsoup as

Elements elements = document.select(".f18").select(".co14").select(".fb").select(".f24");

然后我得到它们.但是当有重复的数字时,例如

then i get them.But when there have some repeating number,such as

<p class="tl f12">2015-12-06 18:19:42 由<span class="co4">咕咚</span>上传<span style="display:none;  margin-top: 5px" class="fr marr15 mc_tips" id="mc_tips_dd5e7f6e-9c02-11e5-a3c1-015176cddf29"><img src="http://static.codoon.com/image/mc/18.gif"></span></p>
        <table cellpadding="0" cellspacing="0" class="f12 co6" route_id="dd5e7f6e-9c02-11e5-a3c1-015176cddf29"  id="dd5e7f6e-9c02-11e5-a3c1-015176cddf29" >
            <tr>
                <td width="70" height="42" class="tc">
                    <div class="m_tc" style="width:32px; height:32px;">
                        <img src="http://static.codoon.com/image/app_icon/walk.png" />
                    </div>
                </td>
                <td width="100" height="42">
                    <span>距离</span><br /><span class="f18 co14 fb f24">0.22</span><span class="f12">公里</span>
                </td>
                <td width="100" height="42">
                    <span>运动时长</span><br /><span class="f18 co14 fb f24">00:03</span>
                </td>
                <td width="120" height="42">
                    <span>平均速度</span><br /><span class="f18 co14 fb f24">3.5</span><span class="f12">公里/小时</span>
                </td>
                <td  width="110">
                    <span>燃烧</span><br /><span class="f18 co14 fb f24">14.9</span>大卡
                </td>
                <td  class="tl" >

                </td>
            </tr>
        </table>
        <p class="tl f12">2015-12-06 17:56:32 由<span class="co4">咕咚</span>上传<span style="display:none;  margin-top: 5px" class="fr marr15 mc_tips" id="mc_tips_a1244433-9bff-11e5-927a-015176b8ab4a"><img src="http://static.codoon.com/image/mc/18.gif"></span></p>
        <table cellpadding="0" cellspacing="0" class="f12 co6" route_id="a1244433-9bff-11e5-927a-015176b8ab4a"  id="a1244433-9bff-11e5-927a-015176b8ab4a" >
            <tr>
                <td width="70" height="42" class="tc">
                    <div class="m_tc" style="width:32px; height:32px;">
                        <img src="http://static.codoon.com/image/app_icon/walk.png" />
                    </div>
                </td>
                <td width="100" height="42">
                    <span>距离</span><br /><span class="f18 co14 fb f24">0.22</span><span class="f12">公里</span>
                </td>
                <td width="100" height="42">
                    <span>运动时长</span><br /><span class="f18 co14 fb f24">00:06</span>
                </td>
                <td width="120" height="42">
                    <span>平均速度</span><br /><span class="f18 co14 fb f24">2.0</span><span class="f12">公里/小时</span>
                </td>
                <td  width="110">
                    <span>燃烧</span><br /><span class="f18 co14 fb f24">13.6</span>大卡
                </td>
                <td  class="tl" >

                </td>
            </tr>
        </table>

它不会像我一样回到我身边 0.22 00:03 3.5 14.9 0.22 00:01 3.3 6.0它返回0.22 00:03 3.5 14.9 00:01 3.3 6.0例如删除重复的号码.那么如何获取所有号码?

it will not return to me as 0.22 00:03 3.5 14.9 0.22 00:01 3.3 6.0it returns 0.22 00:03 3.5 14.9 00:01 3.3 6.0such as delete the repeating number.so how can i get all of my numbers?

这是我的演示在此处输入链接描述

推荐答案

我猜这是一个错误.我在此处的JSoup存储库上创建了一个问题.

I guess this is a bug. I created an issue on the JSoup repository here.

获得所有期望元素的一种方法是不对返回的元素重复执行select方法,而是将它们全部合并为一个select:

One way you get all the expected elements would be to not repeat select method calls on the returned elements, but combine them all into one select:

Elements els = document.select(".f18.co14.fb.f24");

这还将包含重复项.

这篇关于如何使用Jsoup获取重复号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 12:21