/** * 获取html文本中的图片路径 * @param html html文本 * @return */ private String[] getImgs(String html) { String img = ""; Pattern p_image; Matcher m_image; String str = ""; String[] images = null; String regEx_img = "(<img.*srcs*=s*(.*?)[^>]*?>)"; p_image = Pattern.compile(regEx_img, Pattern.CASE_INSENSITIVE); m_image = p_image.matcher(html); while (m_image.find()) { img = m_image.group(); Matcher m = Pattern.compile("src\\s*=\\s*\"?(.*?)(\"|>|\\s+)").matcher(img); while (m.find()) { String tempSelected = m.group(1); if ("".equals(str)) { str = tempSelected; } else { String temp = tempSelected; str = str + "," + temp; } } } if (!"".equals(str)) { images = str.split(","); } return images; }
取html文本中的图片路径
最新推荐文章于 2024-02-06 19:43:44 发布