【问题标题】:Html parsing text from TD Tag从 TD Tag 中解析文本的 HTML
【发布时间】:2013-04-16 10:20:02
【问题描述】:

我有我的 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)。

我正在关注这个link,它是正确的还是解析此文本的更好方法 有人可以帮忙吗?

【问题讨论】:

    标签: java android android-intent html-parsing


    【解决方案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
         }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-03
      • 1970-01-01
      • 2015-02-24
      • 1970-01-01
      • 2015-07-15
      • 1970-01-01
      相关资源
      最近更新 更多