java如何取到如下html中的div内的字符串“需要取的内容”

<div id="apDiv3">
<table height="182" width="100%" cellspacing="3" border="0">
<tbody><tr>
<td height="147" valign="middle" align="center"><a href="details/V8EJJIJ0P.html"><img height="140" width="211" src="../images/group/pic01.jpg" /></a></td>
</tr>
<tr>
<td align="left"><a style=" color:#213964"><strong>需要取的内容</strong></a></td>
</tr>
</tbody></table>
</div>
已用Jsoup解决

很多种方法……
document.getElementByID("aa")
aa.innerHTML就是你要的了

可以用全局document,给每个div 设置id号,或者名字 然后通过全局document访问ID就可以取到内容了,如果在表里面,也可以给表设个ID或者直接某行某列
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-01-07
用js可以很简单的得到啊。
<body>
<div id="apDiv3">
<table height="182" width="100%" cellspacing="3" border="0"> <tbody>
<tr>
<td height="147" valign="middle" align="center"><a href="details/V8EJJIJ0P.html">
<img height="140" width="211" src="../images/group/pic01.jpg" /></a></td>
</tr> <tr> <td align="left"><a style=" color:#213964">
<strong id="ss">需要取的内容</strong></a></td> </tr> </tbody>
</table>
</div>
</body>
<script type="text/javascript">
var str=document.getElementById("ss").innerHTML;
alert(str);

</script>
第2个回答  2013-01-07
先确定 <a style=" color:#213964"><strong> 是不是唯一的,如果是,就好找
Strign。indexOf(Sring)

再 cut 到 </strong>前面追问

不是唯一的。。还有什么方法

追答

div 开始
找表格

找第几行、第几格

追问

能写点具体的代码给参考一下么,之前没有做过类似的

本回答被提问者采纳
第3个回答  2013-01-16
用类选择器
相似回答