爬虫获取email

 /**
  * 爬虫获取email
  * @throws Exception
  */
 public static void getMails_1() throws Exception {

  URL url = new URL("http://www.blogjava.net/gml520/archive/2009/05/20/271691.html");
  
  URLConnection conn = url.openConnection();
  
  BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream(),"UTF-8"));
  
  String line = null;

  String mailreg = "\\w+@\\w+(\\.\\w+)+";

  Pattern p = Pattern.compile(mailreg);

  while (null != (line = br.readLine())) {
  // System.out.println(line);
   Matcher m = p.matcher(line);

   while (m.find()) {
    System.out.println(m.group());
   }
  }
 }

你可能感兴趣的:(email)