java从网页中提取图片地址
import java.util.regex.Matcher;
import java.util.regex.Pattern;
1:这个是拿到一个字符取得里面的图像地址返回一个List
public static List<String> getImgStr(String htmlStr){
String img="";
Pattern p_image;
Matcher m_image;
List<String> pics = new ArrayList<String>();
String regEx_img = "<img.*src=(.*?)[^>]*?>"; //图片链接地址
p_image = Pattern.compile
(regEx_img,Pattern.CASE_INSENSITIVE);
m_image = p_image.matcher(htmlStr);
while(m_image.find()){
img = img + "," + m_image.group();
Matcher m = Pattern.compile("src=\"?(.*?)(\"|>|\\s+)").matcher(img); //匹配src
while(m.find()){
pics.add(m.group(1));
}
}
 
相关文档:
只针对不正常的条件才使用异常
异常只应该被用于不正常的条件,它们永远不应被用于正常的控制流。
下面是一个用异常作遍历结束条件的滥用异常的例子:
//horrible abuse of exceptions. Don't ever do this!
try{
int i=0;
while(true)a[i++].f();
}catch(ArrayIndexOutOfBoundsException e){
......
<!--
/* Font Definitions */
@font-face
{font-family:宋体;
panose-1:2 1 6 0 3 1 1 1 1 1;
mso-font-alt:SimSun;
mso-font-charset:134;
mso-generic-font-family:auto;
mso-font-pitch:variable;
mso-font-signature:3 135135232 16 0 262145 0;}
@font-face
{font-family:"\@宋体" ......
class Global {
public static final String APPNAME= "xyz"; //全局常量
public static String currentUser = "abc"; // 全 ......