簡體   English   中英

如何使用 jsoup 獲取 img src?

[英]How can I get img src with jsoup?

img class="profile-icon-img" alt="" src="https://yt3.ggpht.com/a-/AOh14GhRwaNt-hoxQA1CoiFIXi0f9IalxGKtF8osCw=s68-c-k-c0x00ffffff-no-rj-mo"

我使用它的方式:

String strImg = eContent.get(nIndex).select("img.profile-icon-img").attr("src");

嘗試這個:

 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

暫無
暫無

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

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