I am trying to fetch images from url whose width and height is >249
I tried to fetch image from this url http://imgur.com/gallery/zwxxH8T
'http://www.wallpaper.com/' from few url it is fetching images, but why this is not getting image from all given url.
I am using following code
public static void main(String[] args) {
try {
String path = "http://imgur.com/gallery/zwxxH8T";
System.out.println("Fetching %s..." + path);
try {
URL url = new URL(path);
} catch (MalformedURLException e) {
System.out.println("MalformedURLException");
}
Document doc = Jsoup.connect(path).timeout(5000).get();
Elements media = doc.select("[src]");
int width = 0;
int height = 0;
for (Element src : media) {
if (src.tagName().equals("img")) {
try {
width = Integer.parseInt(src.attr("width"));
height = Integer.parseInt(src.attr("height"));
} catch (NumberFormatException ex) {
}
if ((width > 249) && (height > 249)) {
System.out.println("Path: " + src.attr("abs:src")
+ "\n wd " + src.attr("width") + " hi " + src.attr("height"));
}
}
}
} catch (org.jsoup.UnsupportedMimeTypeException e) {
System.out.println("Exception " + e);
} catch (IOException e) {
System.out.println("Exception " + e);
}
}