[英]Html parsing text from TD Tag
I have my Html data 我有我的HTML数据
<table border='0' cellpadding='3' bgcolor="#CCCCCC" class="hostinfo_title2" width='100%' align="center">
<tr align='center' bgcolor="#ffffff">
<td width='26%' class="hostinfo_title3">Archive Url</td>
</tr>
<tr bgcolor="#ffffff"
<td height="25" align="center">http://www.toradio.com/prgramdetails/20130413_vali_mm.mp3</td>
</tr>
</table>
I want to get mp3 url( http://www.toradio.com/prgramdetails/20130413_vali_mm.mp3 ) from above HTML text. 我想从上面的HTML文本中获取mp3网址( http://www.toradio.com/prgramdetails/20130413_vali_mm.mp3 )。
I'm following this link ,Is it Correct or any better way to parse this text Could any one help? 我正在跟踪此链接 ,它是正确的还是解析此文本的任何更好方法?
Check out JSoup . 查看JSoup 。 It's a nice HTML Parser for JAVA. 这是用于JAVA的不错的HTML解析器。
You should be able to do that with something like this: 您应该可以使用以下方法做到这一点:
String html = "<YOUR HTML HERE>";
Document doc = Jsoup.parse(html);
Elements tds = doc.select("table.hostinfo_title2").select("td");
String mp3Link = "";
for(Element td : tds) {
if(td.text().contains("mp3") {
mp3Link = td.text();
// do something with mp3Link
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.