本文共 665 字,大约阅读时间需要 2 分钟。
先读取网页html代码,然后通过正则表达式提取点邮箱
public static void main(String[] args){
URL url;
try {
url = new URL("http://home.focus.cn/msgview/607/1/9858619.html"); //网页url
HttpURLConnection urlConnection = (HttpURLConnection)url.openConnection(); //连接
urlConnection.connect();
InputStream in = urlConnection.getInputStream(); //获取输入流
byte[] data = new byte[4096];
while (in.read(data) > 0) { //读取流文件
String tempString = new String(data);
String regex2 = "[\\w[.-]]+@[\\w[.-]]+\\.[\\w]+";
Matcher m=Pattern.compile(regex2).matcher(tempString);
while(m.find()) {
System.out.println(m.group());
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
转载地址:https://blog.csdn.net/xiaochangwei789/article/details/7703125 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!