簡體   English   中英

jsoup-如何使用Jsoup提取此圖像?

[英]jsoup - How to extract this image using Jsoup?

我正在尋找這個div中的主要圖像

<div id="imgTagWrapperId" >
<img src ="www.example.com">
</div>

我嘗試了這個:

Document document = Jsoup.connect(url).get();

Elements img = document.select("div[id=imgTagWrapperId] img[src]");

String imgSrc = img.attr("src");

我正在使用的網址是http://www.amazon.in/Google-Nexus-D821-16GB-Black/dp/B00GC1J55C/ref=sr_1_1?s=electronics&ie=UTF8&qid=1421161258&sr=1-1&keywords=Google

這為我工作:

 Document document = Jsoup.connect(url).get();

 Element img = document.getElementById("landingImage");

 String imgSrc = img.attr("data-old-hires");
Document document = Jsoup.connect(url).get();

Elements img = document.select("img[id=landingImage]");

String imgSrc = img.attr("src");

暫無
暫無

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

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