简单小程序抓取网页中的email地址。

 1 import java.io.BufferedReader;
 2 import java.io.FileNotFoundException;
 3 import java.io.FileReader;
 4 import java.io.IOException;
 5 import java.util.regex.Matcher;
 6 import java.util.regex.Pattern;
 7 
 8 
 9 public class EmailSpider {
10 
11     /**
12      * @author zhw
13      * @param args
14      */
15     public static void main(String[] args) {
16         
17         try {
18             BufferedReader br = new BufferedReader(new FileReader("111.txt"));
19             String line = "";
20         
21             while((line = br.readLine())!=null){
22             
23                 Parse(line);
24             
25             }
26             
27             br.close();
28         } catch (FileNotFoundException e) {
29             // TODO Auto-generated catch block
30             e.printStackTrace();
31         } catch (IOException e) {
32             // TODO Auto-generated catch block
33             e.printStackTrace();
34         }
35         
36         
37     }
38 
39     private static void Parse(String line) {
40     
41         Pattern p = Pattern.compile("[\\w[.-]]+@[\\w[.-1]]+\\.[\\w]+");
42         Matcher m = p.matcher(line);
43         while(m.find())
44         System.out.println(m.group());
45         
46         
47     }
48 
49 }
原文地址:https://www.cnblogs.com/elleniou/p/2620374.html