android - Extract image from URL using Jsoup -
i tried extract image other websites following code , had no problems, them tried other website , nothing happend. no image came up.
protected void doinbackground(void... params) { try { // connect web site document document = jsoup.connect(https://www.indiegogo.com/project/spy-cam-peek-i/embedded).get(); // using elements class data elements img = document.select("div.i-project-card i-embedded img[src]"); // locate src attribute string imgsrc = img.attr("src"); //download image url inputstream input = new java.net.url(imgsrc).openstream(); // decode bitmap bitmap = bitmapfactory.decodestream(input); } catch (ioexception e) { e.printstacktrace(); } return null; }
finally y managed grab image.
the image src inside div under attribute data-src this
(<)div class="image" data-src="image.jpg><\div>
so had call class of div call attribute data-src. problem didn't notice there wasn't (<)img> tag calling. final code was
elements img document.select("div.image");
string imgsrc = img.attr("data-src");
cheers everyone.
Comments
Post a Comment