黑马程序员——网页爬虫(网页蜘蛛)
来源:互联网 发布:滴滴打车软件介绍 编辑:程序博客网 时间:2024/05/29 12:46
------- <a href="http://www.itheima.com" target="blank">android培训</a>、<a href="http://www.itheima.com" target="blank">java培训</a>、期待与您交流! ----------
-通过学习IO流,网络编程,正则表达式等知识编写一个用于获取电子邮箱的程序——网页爬虫
package day25;import java.io.*;import java.net.*;import java.util.regex.Matcher;import java.util.regex.Pattern;public class GetMailDemo {public static void main(String[] args) throws Exception {getNetMails();}//取得网络上的Emailpublic static void getNetMails() throws Exception{URL url= new URL("http://10.0.31.236:8080/testWeb/email.html");URLConnection conn= url.openConnection();BufferedReader bufIn= new BufferedReader(new InputStreamReader(conn.getInputStream()));String line= null;String mailreg= "\\w+@\\w+(\\.\\w+)+";Pattern p= Pattern.compile(mailreg);while((line=bufIn.readLine())!=null){//System.out.println(line);Matcher m= p.matcher(line);while(m.find()){System.out.println(m.group());}}}//取得本地文件中的Emailpublic static void getMails() throws Exception{@SuppressWarnings("resource")BufferedReader bufr= new BufferedReader(new FileReader("mail.txt"));String line= null;String mailreg= "\\w+@\\w+(\\.\\w+)+";Pattern p= Pattern.compile(mailreg);while((line=bufr.readLine())!=null){//System.out.println(line);Matcher m= p.matcher(line);while(m.find()){System.out.println(m.group());}}}}
0 0
- 黑马程序员——网页爬虫(网页蜘蛛)
- 黑马程序员-正则表达式(网页爬虫)
- 黑马程序员——正则表达式和网页爬虫
- 黑马程序员_网页爬虫
- 黑马程序员_正则表达式(网页爬虫)
- 黑马程序员-正则表达式、网页爬虫
- 黑马程序员-----正则表达式和网页爬虫
- 黑马程序员——JAVA基础---正则表达式---概述,匹配、切割、替换、提取,网页爬虫
- 网络爬虫(网络蜘蛛)之网页抓取
- 网络爬虫(网络蜘蛛)之网页抓取
- 网络爬虫(网络蜘蛛)之网页抓取
- 网络爬虫(网络蜘蛛)之网页抓取
- 网络爬虫(网络蜘蛛)之网页抓取
- 《黑马程序员》The ninth day (网页爬虫和反射,刺激!)
- 黑马程序员 分享一个牛叉的网页爬虫
- 《黑马程序员》 javaweb网页爬虫技术的实现
- 黑马程序员_java 正则表达式基本方法与网页爬虫
- 黑马程序员_温习 正则表达式 (个人笔记)摘要(正则表达式-----网页爬虫)
- 黑马程序员——正则表达式
- intersection of circle and sector
- iOS开发笔记16--第三方登陆
- Google IO 2015
- iOS开发笔记17-SEL (@selector) 原理及使用总结(一)
- 黑马程序员——网页爬虫(网页蜘蛛)
- iOS开发笔记18--SEL (@selector) 原理及使用总结(二)
- 黑马程序员——反射Reflection
- 鞍山办假证__百度文库af
- 网络编程————UDP
- Android屏幕适配全攻略(最权威的官方适配指导)
- 网络编程————TCP
- 晨昏蒙影
- Retrieve Last Log After Crash