How to parse out the value of src attributes of imgs tag from a html source

Viewed 71

I'm trying to get all images from a site and show them in recycler view.

The site I'm using is (mem generator)

enter image description here

I want to get this highlighted src string and show these images in my recycler view and what I'm doing for that is

 String searchURL = url+page;
            Connection connect = Jsoup.connect(searchURL);
            connect.userAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.21 (KHTML, like Gecko) Chrome/19.0.1042.0 Safari/535.21");
            connect.timeout(100000);
            try {
 
                Document document = connect.get();
                Element element = document.getElementById("mt-boxes-wrap");
                 Elements value = element.parent().getElementsByClass("mt-img-wrap");
                value.get(0).childNode(0);
                System.out.println("test 1" +  value.get(0).childNode(0));

            } catch (IOException e) {

                e.printStackTrace();
            }
            return null;

On applying debugger, this is how I'm getting the values.As you can see in this pic the value I'm getting is in

Value item 1 -> child's 1 -> child's 1 -> attribute -> value 3

enter image description here

I couldn't able to access the value within the attribute tag. I tried by getting value from image class shadow which is present within div tag but it gave me index out of bound exception. I tried some other solutions from StackOverflow but didn't get my answer.

0 Answers
Related