Crawl Mailboxes and resources

Source: Internet
Author: User

Using system;using system.collections.generic;using system.componentmodel;using system.data;using System.Drawing; Using system.linq;using system.text;using system.threading.tasks;using system.windows.forms;using System.IO;using    system.net;using system.text.regularexpressions;namespace windowsformsapplication1{public partial class Form1:form        {public Form1 () {InitializeComponent (); The public string getwebcontent (string url, Encoding encode)//encode encoding {URL = textbiaoti. Text.trim (); Need to get the source code of the webpage WebRequest request = webrequest.create (URL); WebRequest.Create method, returns the WebRequest subclass HttpWebRequest WebResponse response = Request. GetResponse (); The Webrequest.getresponse method returns the response to the Internet request Stream Resstream = response. GetResponseStream ();               The WebResponse.GetResponseStream method returns a data stream from an Internet resource. Encoding enc = encoding.getencoding ("Utf-8"); If it is garbled, change to Utf-8/GB2312 StReamreader sr = new StreamReader (Resstream, ENC); Namespace: System.IO.               The StreamReader class implements a TextReader (TextReader class that represents a reader that can read a series of sequential characters) so that it reads characters from a byte stream in a specific encoding. Contenthtml.text = Sr. ReadToEnd ();        Output (HTML code), TextBox control contenthtml to multiline mode return contenthtml.text;  private void Button1_Click (object sender, EventArgs e) {try {string x = Getwebcontent (Textbiaoti.                Text, Encoding.UTF8);                Contenthtml.text = ""; Regex r = new Regex (@ "/^\w+ ([-+.] \w+) *@\w+ ([-.] \w+) *\.\w+ ([-.] \w+) *$/");//Regular System.Text.RegularExpressions.MatchCollection MC = r.matches (x);//means the regular expression pattern is applied iteratively to the input character The collection of successful matches found by the string. The System.Text.RegularExpressions Reference namespace (x) is the string to search for matches//The collection is immutable (read-only), and there is no public constructor.                The Regex.Matches method returns the MatchCollection object.                The collection contains 0 or more System.Text.RegularExpressions.Match objects. If the match succeeds, a System.Text.RegularExpressions.Ma corresponding to each match found in the input string is used.The Tch object to compute the collection.                If the match is unsuccessful, the collection does not contain the System.Text.RegularExpressions.Match object, and its Count property equals 0. for (int i = 0; I < MC. Count; i++) {if (MC. Count = = 0) {Contenthtml.text = "No information is queried for the email address.                    "; } else {contenthtml.text + = Mc[i].                    Value + "\ r \ n"; }}} catch (Exception ex) {MessageBox.Show ("Get Site Information error:" + Ex.            Message); }} private void Button2_Click (object sender, EventArgs e) {string x = Getweb Content (Textbiaoti.            Text, Encoding.UTF8);            int a = X.indexof ("

  

Crawl Mailboxes and resources

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.