import java.io.*;
import java.net.*;
import java.util.regex.*;
public class YouXiangHuoQu {
public static void main(String[] args) throws Exception {
getMail();
}
public static void getMail() throws Exception{
URL url=new URL("http://www.byjth.com");//网页地址
URLConnection conn=url.openConnection();
BufferedReader bufin=new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line=null;
String mailreg="\\w+@\\w+(\\.\\w+)+";//正则匹配
Pattern p=Pattern.compile(mailreg);
while((line=bufin.readLine()) != null){
Matcher m=p.matcher(line);
while(m.find()){
System.out.print(m.group()+"\r\n");
}
}
}
}
java网络爬虫之邮箱采集器源码分享
http://www.byjth.com/thread-2282-1-1.html
(出处: 天黑社区)
转载于:https://blog.51cto.com/byjth/1357846
本文分享了一段Java网络爬虫源码,该爬虫能够从指定网站抓取并匹配电子邮箱地址。通过使用正则表达式进行邮箱匹配,展示了如何创建URL连接、读取网页内容及解析匹配结果。
228

被折叠的 条评论
为什么被折叠?



