java - JSoup not printing all elements in HTML table row -
i trying elements in html table row using jsoup. however, seems consistently omit columns , print half of columns in table. instance, if have html table so:
<table id="resulttable" width="100%" border="1" cellpadding="1" cellspacing="0" bordercolor="#ffffff"> <tbody> <tr class="table"> <td align="right">1</td> <td align="right">4</td> <td><div>name</div></td> <td><div>country</div></td> <td><div>club</div></td> <td><div>sr</div></td> <td align="right"><div>56.00 (5)</div></td> <td align="right"><div>51.62 (3)</div></td> <td align="right"><div>1:47.62</div></td> </tr> </tbody> </table>
and try printing cells so:
document doc = jsoup.parse(html); //html string containing full html page elements tablerows = doc.select("tr.table"); (element tablerow : tablerows) { system.out.println(tablerow.text()); }
for reason, cells ever printed 1st, 3rd , 9th cell.
you can find full html here. (it's website used displaying live timing of alpine ski races). sake of brevity included 1 <tr>
tag, website contains hundreds of them. also, don't know if matters, every <div>
calls javascript function onmouseover
, onmouseout
.
is problem bad html? thought jsoup took care or cleaning bad html. or not using jsoup properly?
thanks help.
edit: fixed it. using , android webview, had not realized loading mobile site instead of desktop version.
firstly make sure html
is: the source downloaded url
or the full html copied browser
.if the source
, nothing due page dynamic , table load http://live-timing.com/includes/aj_race.php?r=163390&&m=1&&u=5(maybe can try result directly url).if the full html
, selector syntax has no problem, can try in https://try.jsoup.org/, result correct.
Comments
Post a Comment