[C #] GetHtmlSource,
Key code:
/// <Summary> /// obtain the HTML source code of the webpage // </summary> /// <param name = "url"> link eg: http://www.baidu.com/ </Param> // <param name = "charset"> Encoding eg: Encoding. UTF8 </param> // <returns> HTML source code </returns> public static string GetHtmlSource (string url, Encoding charset) {string _ html = string. empty; try {HttpWebRequest _ request = (HttpWebRequest) WebRequest. create (url); HttpWebResponse _ response = (HttpWebResponse) _ request. getResponse (); using (Stream _ stream = _ response. getResponseStream () {using (StreamReader _ reader = new StreamReader (_ stream, charset) {_ html = _ reader. readToEnd () ;}} catch (WebException ex) {using (StreamReader sr = new StreamReader (ex. response. getResponseStream () {_ html = sr. readToEnd () ;}} catch (Exception ex) {_ html = ex. message;} return _ html ;}
Test code:
public static void GetHtmlSourceTest() { string _url = "http://www.baidu.com/"; string _htmlSource = HttpWebRequestUtilsV2.GetHtmlSource(_url, Encoding.UTF8); Console.WriteLine(_htmlSource); }
Test results:
. Csharpcode ,. csharpcode pre {font-size: small; color: black; font-family: Las LAS, "Courier New", courier, monospace; background-color: # ffffff; /* white-space: pre ;*/}. csharpcode pre {margin: 0em ;}. csharpcode. rem {color: #008000 ;}. csharpcode. kwrd {color: # 0000ff ;}. csharpcode. str {color: #006080 ;}. csharpcode. op {color: # effecc0 ;}. csharpcode. preproc {color: # cc6633 ;}. csharpcode. asp {background-color: # ffff00 ;}. csharpcode. html {color: #800000 ;}. csharpcode. attr {color: # ff0000 ;}. csharpcode. alt {background-color: # f4f4f4; width: 100%; margin: 0em ;}. csharpcode. lnum {color: #606060 ;}
What is pc?
PC is a computer
A notebook is also called a computer.
Tablets are also called computers
PC (personal computer), derived from IBM's first desktop computer model PC in 1978, before which there was an Apple II personal computer. Personal computers that can run specific functions independently. Personal computers do not need to share the processing, disks, printers, and other resources of other computers. Today, the term PC refers to all personal computers, such as desktop computers, notebook computers, or personal computers compatible with IBM systems.
What is pc
1. PC.
2. I personally think it may also mean surfing the Internet. In Korean, "PC networking" means Internet cafes,
This is also possible if the author of this article is also Han serverplaygroup.