public class GetImagePathUtil {
/**
* 得到网页中图片的地址
*/
public static Set
Set
String img = "";
Pattern p_image;
Matcher m_image;
// String regEx_img = "
String regEx_img = "
p_image = Pattern.compile
(regEx_img, Pattern.CASE_INSENSITIVE);
m_image = p_image.matcher(htmlStr);
while (m_image.find()) {
// 得到数据
img = m_image.group();
// 匹配中的 src 数据
Matcher m = Pattern.compile("src\\s*=\\s*\"?(.*?)(\"|>|\\s+)").matcher(img);
while (m.find()) {
pics.add(m.group(1));
}
}
return pics;
}
}
来源: http://www.bubuko.com/infodetail-2450740.html