簡體   English   中英

jsoup從表td獲取URL

[英]jsoup getting the url from table td

Element tables = doc.select("table")
Elements myTds = tables.select("td:eq(0)");

.....

thetext=td.text();
thehref=td.getElementsByTag("a[href]");

我正在從HTML頁面讀取表格。 我想讀

<td>
<a href="student-profiles/andy.html">Andy</a>
</td>

我想閱讀安迪和學生資料。 文本正在印刷安迪。 如何獲得href? 我嘗試了幾件事,但未能成功。

//thehref=td.getElementsByTag("a“);

function simpleURL(){
        var anchors = document.getElementsByTagName('a');
        if(anchors != null & anchors.length > 0){
                thehref= anchors[1].href;  

        }       
    }

我能夠做到這一點:

元素myTds = table.select(“ td:eq(0)”); 比tds.attr(href);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM