Regular Expressions--—— web crawlers

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.