黑马程序员技术交流社区

标题: 获取一个网页上的邮箱地址 [打印本页]

作者: 千山万水    时间: 2015-8-25 23:20
标题: 获取一个网页上的邮箱地址
  1. 需求:

  2. 获取一个网页上的邮箱地址

  3. */

  4. import java.io.BufferedReader;

  5. import java.io.InputStreamReader;

  6. import java.util.regex.Pattern;

  7. import java.util.regex.Matcher;

  8. import java.net.URL;

  9. public classTest{


  10. public static void main(String...args)throws Exception{

  11. URL url =new URL("http://127.0.0.1:8080/");

  12. BufferedReader bufin =  

  13. new BufferedReader(new InputStreamReader(url.openStream()));

  14. String line =null;

  15. String regex = "[1-9a-zA-z]\\w+@\\w+(\\.\\w+)+";

  16. Pattern p =Pattern.compile(regex);

  17. while((line=bufin.readLine())!=null){

  18. Matcher m = p.matcher(line);

  19. while(m.find()){

  20. System.out.println(m.group());

  21. }

  22. }

  23. }

  24. }

复制代码

作者: pengbeilin    时间: 2015-8-25 23:45
用了文本框的界面,然后在文本框中输入网站就可以把网站页面中的邮箱扣出来存入自己设置的文档中。有兴趣的话可以写一下




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2