这是我的html
<script src="/ClientScripts/swfobject.js" language="javascript" type="text/javascript"> </script>
<div class="contentDetails">
<div id="ctl00_MainContentPlaceHolder_ContentDetailsBodyDivision" class="body">
<div align="justify">
<p align="center"><img width="500" height="352" alt="MVM315" src="/UserUpload/Image/1(825).jpg" /></p>
<p align="center"><img width="500" height="352" alt="MVM315" src="/UserUpload/Image/2(598).jpg" /></p>
如何使用 jsoup 获取 {src="/UserUpload/Image/1(825).jpg"
}?
我有这个代码但是不能用
Document doc = Jsoup.parse(html);
Elements mElements = doc.select("div[id^=ctl00_MainContentPlaceHolder_ContentDetailsBodyDivision]");
Result = mElements.get(0).tagName("img").toString();
最佳答案
试试这个:
Element imageElement = document.select("img").first();
String absoluteUrl = imageElement.absUrl("src"); //absolute URL on src
String srcValue = imageElement.attr("src"); // exact content value of the attribute.
更多信息在这里:http://jsoup.org/cookbook/extracting-data/working-with-urls
关于android - 使用 jsoup 获取 img src,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25623396/