Android JSOUP获取Table的元素

时间:2015-08-28 07:39:05

标签: android html jsoup

有一份足球运动员名单及其图像和详细信息链接。 如何通过jsoup for android获取这些信息?

我需要href,src,播放器名称

http://www.trabzonspor.org.tr/default.asp?Sayfa=Sporcular&IND=1#Icerik



<table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" 
bordercolor="#9DC5EC" width="32%" id="AutoNumber54" height="1%">
<tbody><tr>
<td width="100%" height="118">
														  
<a href="?Sayfa=SporcuDetay&amp;IND=586#Icerik">
														  
<img border="0" src="/Upload/Sporcu/kucuk/14_08_2015-7S4D.jpg" width="136" height="118" 
style="FILTER: alpha(opacity=30)" onmouseover="nereidFade(this,100,70,15)" onmouseout="nereidFade(this,30,80,9)">
</a>
 </td>
</tr>
<tr>
<td width="100%" height="25" bgcolor="#4F0000"> <p align="center"><b><font face="Arial" size="1" color="#FFFFFF">
Esteban Alvarado Brown </font></b></p></td>
</tr>
</tbody></table>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

I have solved, it is working 

类MyAsyncTask扩展了AsyncTask {

    @Override
    protected Void doInBackground(Void... voids) {
        Document doc = null;
        try {
            doc = Jsoup.connect("http://www.trabzonspor.org.tr/default.asp?Sayfa=Sporcular&IND=1#Icerik/").get();
            //id si AutoNumber34 olan table ları alıyoruz. Sorgu sonucunda 34 adet veri geliyor....
            Elements player = doc.select("table#AutoNumber54");
            for (Element p : player) {
                // a href etiketini alıyoruz.....
                Elements linkHref = p.select("a[href]");
                // img with src ending .jpg
                Elements image = p.select("img[src$=.jpg]");

                //başına href yazmamızın nedeni linke tamamıyla ulaşabilmek....
                String absHref = linkHref.attr("abs:href");
                String imagee = image.attr("abs:src");



            }


        } catch (IOException e) {
            e.printStackTrace();
        }


        return null;
    }
}