티스토리 뷰

package getemail;

import java.io.IOException;
import java.util.HashSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class GetEmailAddr {
	
	static String url="https://newsis.com/view/?id=NISX20200623_0001068975&cID=10101&pID=10100";
	
	public static void fillEmailsHashSet(String line,HashSet<String> container){
        Pattern p = Pattern.compile("([\\w\\-]([\\.\\w])+[\\w]+@([\\w\\-]+\\.)+[A-Za-z]{2,4})");
        Matcher m = p.matcher(line);
        while(m.find()) {
            container.add(m.group(1));
        }
	}
	
	public static void main(String[] args) throws IOException {
		Connection.Response response = Jsoup.connect(url)
                .method(Connection.Method.GET)
                .execute();
		Document d = response.parse();
		//System.out.println(d);
		String s=d.toString();
		
		HashSet<String> hs = new HashSet<>();
		fillEmailsHashSet(s, hs);
		for (String string : hs) {
			System.out.println(string);
		}
	}
}
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함