As shown below:
/** * Get the address of the image in the webpage* @param sets html string*/ public Set<String> getImgStr(String htmlStr) { Set<String> pics = new HashSet<String>(); String img = ""; Pattern p_image; Matcher m_image; String regEx_img = "<img.*src//s*=//s*(.*?)[^>]*?>"; p_image = Pattern.compile(regEx_img, Pattern.CASE_INSENSITIVE); m_image = p_image.matcher(htmlStr); while (m_image.find()) { // Get <img /> data img = m_image.group(); // Match src data in <img>Matcher m = Pattern.compile("src//s*=//s*/"?(.*?)(/"|>|//s+)").matcher(img); while (m.find()) { pics.add(m.group(1)); } } return pics; }The above article Java's method to obtain the content in src under the img tag in Html text is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.