android java get html image tag from string

后端 未结 4 576
深忆病人
深忆病人 2020-12-10 07:33

Im trying to get HTML image tag url from the given string. There should be some regular expression to get it. But don\'t know how to do it. Can anyone help me on this.

4条回答
  •  感动是毒
    2020-12-10 07:53

    I use jsoup. It is pretty easy to use and lightweight. Some versions were not Java 1.5 compatible but it appears they fixed the issue.

    String html = str;
    Document doc = Jsoup.parse(html);
    Elements pngs = doc.select("img[src$=.png]"); // img with src ending .png
    

提交回复
热议问题