zoukankan      html  css  js  c++  java
  • 简单小程序抓取网页中的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 }
  • 相关阅读:
    Codeforces_462_B
    Codeforces_460_B
    Codeforces_456_A
    2016.11.27
    Buy the Ticket{HDU1133}
    高精度模板
    盐水的故事[HDU1408]
    测试你是否和LTC水平一样高[HDU1407]
    完数[HDU1406]
    Air Raid[HDU1151]
  • 原文地址:https://www.cnblogs.com/elleniou/p/2620374.html
Copyright © 2011-2022 走看看