网络蜘蛛(收集网页中的邮箱地址信息)

public class SpiderEx {
public void getMails() throws Exception {
URL url = new URL("http://www.hncu.cn");//收集的网页
BufferedReader bReader = new BufferedReader(new InputStreamReader(url.openStream()));//字节流与字符的转换
String regex="\\w+@\\w+(\\.\\w+)+";//正则表达式
Pattern p=Pattern.compile(regex);
String str=null;
while((str=bReader.readLine())!=null){
Matcher m=p.matcher(str);
while(m.find()){
System.out.println(m.group());
}

}
}
}

猜你喜欢

转载自blog.csdn.net/qq_35307947/article/details/80572818
今日推荐