I am trying to extract the latest info from the following :
Below is the html code that I am looking at, but I have no idea how to tackle this problem using Jsoup? The problem is that there are many classes called "UL1", multiple "Last" and many "td" within the html . I need to get the current price which is "31.4" in this case.
<td rowspan="2" class="bg1 W1">
<ul class="UL1"><li class="LI1 font12_grey W1">Last</li></ul>
<ul class="UL1"><li class="LI2 font28 C bold W1"><span class="neg bold">31.400</span></li></ul>
<ul class="UL1 none" style="display:none;"><li class="LI1 C W1">
<img src="/en/Images/Stock/icon_see.gif" border=0 /><a id="ctl00_ctl00_cphContent_cphContent_lnkAddMonitor" class="font12a" href="#">Monitor</a><img src="/en/Images/Stock/icon_group.gif" border=0 /><a id="ctl00_ctl00_cphContent_cphContent_lnkAddPortfolio" class="font12a" href="#">Portfolio</a>
</li></ul>
</td>
You can look for the ul
element that contains the text Last
then find the next sibling:
ul:contains(Last) + ul>li>span
You can find a demo here.