vjame

优化代码是无止境的
随笔 - 65, 文章 - 9, 评论 - 26, 引用 - 0
数据加载中……

从网页中提取电子邮箱地址

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class EmailSpider {

    
public static void main(String[] args) {
        
try {
            BufferedReader br 
= new BufferedReader(new FileReader("D:\\share\\courseware\\1043633.html"));
            String line 
= "";
            
while((line=br.readLine()) != null) {
                parse(line);
            }
        } 
catch (FileNotFoundException e) {
            
// TODO Auto-generated catch block
            e.printStackTrace();
        } 
catch (IOException e) {
            
// TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

    
private static void parse(String line) {
        Pattern p 
= Pattern.compile("[\\w[.-]]+@[\\w[.-]]+\\.[\\w]+");
        Matcher m 
= p.matcher(line);
        
while(m.find()) {
            System.out.println(m.group());
        }
    }

}

posted on 2009-02-09 13:25 lanjh 阅读(2147) 评论(1)  编辑  收藏 所属分类: Java App

评论

# re: 从网页中提取电子邮箱地址  回复  更多评论   

有没有这方面的软件啊?我想要一个
2009-03-26 23:23 | QQ网址库

只有注册用户登录后才能发表评论。


网站导航: