美文网首页
网络爬虫之抓取邮箱

网络爬虫之抓取邮箱

作者: 全满 | 来源:发表于2018-06-18 20:28 被阅读0次
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    
    /*
     抓取邮箱号码
     */
    public class Demo7 {
        public static void main(String[] args) {
            String str = "有事没事联系:1122423@qq.com 有事没事联系:1122423@qq.com 有事没事联系:1122423@qq.com "
                    + "有事没事联系:1122423@qq.com 有事没事联系:1122423@qq.com 有事没事联系:1122423@qq.com"
                    + "有事没事联系:1122423@qq.com 有事没事联系:1122423@qq.com.cn 有事没事联:1122423@qq.com.cn"
                    + "有事没事联系:1122423@163.com 有事没事联系:1122423@qq.net";
            String reg = "[a-zA-Z1-9]\\w{1,11}@[a-zA-Z0-9]{2,}(\\.[a-z]{2,3}){1,2}";
            /*
             第一步:
                先要把字符串的正则编译成Pattern对象
            */
            Pattern p = Pattern.compile(reg);
            /*
             第二步:
                把正则对象匹配字符串对象得到一个匹配器
             */
            Matcher m = p.matcher(str);
            while(m.find()){
                System.out.println(m.group());
            }
        }
    }
    
    

    相关文章

      网友评论

          本文标题:网络爬虫之抓取邮箱

          本文链接:https://www.haomeiwen.com/subject/oltoeftx.html