Web crawler
import java.net.*;import java.io.*;import java.util.regex.*;class findmail{public Static void main (String[] args) throws exception{//read stream associate file//bufferedreader bin = new bufferedreader (New filereader ("Mail.txt"));//Get the data on the page need to get the input stream urlconnection getInputStream () from the web-side to get the input stream Url url = new url ("http/ 127.0.0.1:8080/myweb/mail.html "); Urlconnection conn = url.openconnection (); Bufferedreader bin = new bufferedreader (New inputstreamreader (Conn.getInputStream ())) ; string line = null;//definition Mailbox format regular rule string mailreg = "\\w{2,13}@\\w {2,5} (\\. [a-z]+) + ";//Regular rule Package mode Object Pattern p = pattern.compile (Mailreg);while ((line = bin.readline ())!=null) {matcher m = p.matcher (line);//associate a pattern with a string if (M.find ()) { System.out.println (M.group ());} System.out.prinTLN (line);}}}
This article comes from "either desperately, or roll back!" "Blog, be sure to keep this provenance http://jiangzuun2014.blog.51cto.com/8732469/1440433
Regular Expressions--—— web crawlers