1. Class libraries that need to be referenced
Copy Code code as follows:
Using System.Net;
Using System.IO;
Using System.Text;
Using System.Text.RegularExpressions;
2. Access to other Web site content key code
Copy Code code as follows:
WebRequest request = WebRequest.Create ("http://target URL. com/");
WebResponse response = Request. GetResponse ();
StreamReader reader = new StreamReader (response. GetResponseStream (), encoding.getencoding ("gb2312"));
Reader. ReadToEnd () to get the source of the Web page
TextBox1.Text = reader. ReadToEnd ();
3. Access to other Web page source code after the {regular expression} handsome select useful information
Copy Code code as follows:
MatchCollection Titlematchs = regex.matches (reader. ReadToEnd (), @ "Post comments </a></p></div><div class=" "Body" > ([\s\s]*?) </div><div class= "" Share "" > ", Regexoptions.ignorecase | Regexoptions.multiline);
foreach (Match nextmatch in Titlematchs)
{
S + + "<br>" + nextmatch.groups[1]. Value;
TextBox1.Text = "\ n" + nextmatch.groups[1]. Value;
}
Regexoptions.ignorecase: The case is not case-sensitive, general site source code is not sensitive to the case, so cancel it.
Regexoptions.multiline: The choice of many lines of content is handsome.
4. Done
Not on the map! Bad Influence! Forgive me forgive
Code package download in the text