java - 如何使用 jsoup 获取 img src?

标签 java android 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

关于java - 如何使用 jsoup 获取 img src?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60503065/

相关文章:

java - 从基类方法调用基类重写函数

java - java代码中的SQL错误 "Column count doesn' t匹配第1行的值计数“

安卓 ImageView

java - 如何在 JPA (eclipselink) 中使用 joda 时间?

java - 需要一种使用 xmlSuites 在 TestNG 中顺序运行测试的方法

android - 导入高分辨率照片 android 应用程序无法正常工作

android - 如何在不单击标记的情况下显示标记的标题?

java - 从网站获取超链接

java jsoup 删除新行

java - 如何在android studio中用jsoup获取这个元素