简体   繁体   English

使用jsoup在HTML中提取图像src

[英]Extracting image src in HTML with jsoup

在此处输入图片说明

I tried to get the .png file's link with this code. 我尝试使用此代码获取.png文件的链接。

e = rawData.select("img[class=competitive-rank]");
    for(Element el : e){
      playerRankIconURL = el.attr("src");
      println(playerRankIconURL);
    }

But it seems to be not working properly...what am I doing it wrong? 但这似乎无法正常工作...我做错了什么?

Your selector is looking for an img with the class competitive-rank , but there isn't one. 您的选择器正在寻找一个competitive-rankimg ,但没有一个。 It's the div which has that class. 是具有该类的div

You probably instead want to select an img which is contained by a div with that class, which you could do with the selector div.competitive-rank img . 相反,您可能想选择一个该类的div 包含img 可以使用选择器div.competitive-rank img

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

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