0

I need to get the image link from HTML, that is located (img) between < a >< /a>

MainActivity:

private void getWebsite() {
        new Thread(new Runnable() {
            @Override
            public void run() {
                final StringBuilder builder = new StringBuilder();

            try {
                Document doc = Jsoup.connect(domain + "account").get();
                String title = doc.title();
                Elements elements  = doc.getElementsByClass("gravatar avatar avatar-120");

                builder.append(title).append("\n");

                for (Element e : elements ) {
                    builder.append("\n").append("Link : ").append(e.attr("src")) ;
                }
            } catch (IOException e) {
                builder.append("Error : ").append(e.getMessage()).append("\n");
            }

            Log.d("HTML", builder.toString());

            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    //ProfileImgUrl = builder.toString();
                    result.setText(builder.toString());
               }
            });
        }
    }).start();
}

HTML:

other <img> tag
<a href="website link">
    <img src="image link" class="gravatar avatar avatar-120" etc...>
</a>
other <img> tag

I expect to get the image link, but the result is some other text.

مشترياتي
  • 69
  • 1
  • 1
  • 7

0 Answers0