简体   繁体   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]");

I am reading a table from a HTML page. 我正在从HTML页面读取表格。 I want to read the 我想读

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

I want to read Andy and student-profiles. 我想阅读安迪和学生资料。 thetext is printing Andy. 文本正在印刷安迪。 How can I get the href? 如何获得href? I tried a couple of things but could not. 我尝试了几件事,但未能成功。

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

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

        }       
    }

I was able to do this: 我能够做到这一点:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM