Today, I have nothing to worry about using regular expressions. I used regular expressions for verification. I used them for the first time to capture webpages,
I grabbed the list of Recommendation articles on several pages on the blog homepage ....
The code is very simple and I will not explain it. It must be not rigorous. I am familiar with the following regular expressions and methods used to capture webpage content...
Using System;
Using System. Web;
Using System. Web. UI;
Using System. Text. RegularExpressions;
Using System. Net;
Using System. IO;
Public partial class test: Page
{
Public int g = 0;
Public string dfdf = "";
Void Page_Load (object sender, System. EventArgs e)
{
For (int I = 2; I <10; I ++)
{
WebRequest rque = WebRequest. Create ("http://www.cnblogs.com/p" + I. ToString ());
WebResponse utxt = rque. GetResponse ();
Stream str = utxt. GetResponseStream ();
StreamReader sread = new StreamReader (str, System. Text. Encoding. UTF8 );
String pram = @ "MatchCollection m = Regex. Matches (sread. ReadToEnd (), pram );
Foreach (Match MS in m)
{
G + = 1;
Dfdf = dfdf + ms. groups [1]. value. toString () + ms. groups [2]. value. toString () + "<br/> ";
}
}
Response. Write ("Total number of records:" + g. ToString () + "<br/>" + dfdf );
}
}