vipwolf

用java写的,而且是用来爬邮箱的,关于邮箱的正则只是随便写写,需要优化,仅供娱乐。

import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class spider {
 public static void main(String[] args) {
  try {
   getMail();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 public static void getMail() throws Exception {
  URL url = new URL("需要爬邮箱的网址");
  URLConnection conn = url.openConnection();
  BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
  
  String regex = "[a-zA-Z0-9]{6,12}@[a-zA-Z]{2,8}(\\.[a-zA-Z]{2,3}){1,2}";
  String line = null;
  while((line = in.readLine()) != null){
   Pattern p = Pattern.compile(regex);
   Matcher m = p.matcher(line);
   while(m.find()){
    System.out.println(m.group());
   }
  }
 }
}

分类:

技术点:

相关文章:

  • 2021-09-03
  • 2021-12-27
  • 2021-07-30
  • 2022-12-23
  • 2022-02-25
  • 2022-12-23
  • 2021-11-22
猜你喜欢
  • 2021-11-29
  • 2022-03-02
  • 2021-10-17
  • 2021-04-05
  • 2021-11-17
  • 2021-11-28
  • 2021-11-29
相关资源
相似解决方案