获取URL内容


Warning: Undefined array key "HTTP_REFERER" in /www/wwwroot/prod/www.enjoyasp.net/wp-content/plugins/google-highlight/google-hilite.php on line 58

????? string url = @”http://www.input8.com/ip/?ip=59.38.240.54“;
??????????? HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
??????????? httpWebRequest.Method = “GET”;
??????????? HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
??????????? if (((int)httpWebResponse.StatusCode) >= 400)
??????????? {
?????????????? ????? return;
??????????? }
??????????? Stream responseStream = httpWebResponse.GetResponseStream();
??????????? StreamReader streamReader = new StreamReader(responseStream, Encoding.UTF8);
??????????? String result = streamReader.ReadToEnd().Trim();?? //result为得到的URL源码
??????????? httpWebResponse.Close();
??????????? streamReader.Close();