/**
* 提取html中a标签的href
* @param strs
* @return
*/
public List<String> getAHref(String strs){
List<String> al=new ArrayList<String>();
String regex="<a.*?/a>";
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;
}
提取HTML中所有a标签的href链接
最新推荐文章于 2022-05-17 15:52:32 发布