提取HTML中所有a标签的href链接

/**
	 * 提取html中a标签的href
	 * @param strs
	 * @return
	 */
	public List getAHref(String strs){
        List  al=new ArrayList();
        String regex="";
        
        Pattern pt=Pattern.compile(regex);
        Matcher mt=pt.matcher(strs);
 
        while(mt.find()){
        	String s3 = "href=\"(.*?)\"";
            Pattern pt3=Pattern.compile(s3);
            Matcher mt3=pt3.matcher(mt.group());
            while(mt3.find())
            {
                System.out.println("网址:"+mt3.group().replaceAll("href=|>",""));
                String u=mt3.group().replaceAll("href=|>","");
                al.add(u);
            }
        }
		return al;
    }

你可能感兴趣的:(java)