kymbrik
11/11/2017 - 12:05 PM

Using if statement inside try-catch block not working for JSoup

The code

if(link.select("img.a-dynamic-image.a-stretch-vertical").equals(null)){
makes no sense. select returns an Elements collection, which will never be .equals(null). If you want to check whether the select returns anything, use isEmpty or look at the size of the returned collection:

if(link.select("img.a-dynamic-image.a-stretch-vertical").isEmpty()){
    // It's empty