0

私は自分の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>

上記の HTML テキストからmp3 の URL ( http://www.toradio.com/prgramdetails/20130413_vali_mm.mp3 )を取得したいと考えています。

私はこのリンクをたどっています、それは正しいですか、それともこのテキストを解析するためのより良い方法ですか?

4

1 に答える 1

1

JSoupをチェックしてください。Java 用の素晴らしい HTML パーサーです。

次のようなものでそれを行うことができるはずです:

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
     }
}
于 2013-04-16T10:28:00.430 に答える