WebRequest req = WebRequest.Create(uri); WebResponse res = req.GetResponse(); // GetResponse blocks until the response arrives Stream ReceiveStream = res.GetResponseStream(); // Read the stream into a string StreamReader sr = new StreamReader( ReceiveStream ); string resultstring = sr.ReadToEnd();
我想他说的不一定是asp.net, 可能是console app或其他吧。楼主可以把你的background说一下。
WebClient mywebClient = new WebClient();
byte[] mydatabuffer = mywebClient.DownloadData(url);
string html = Encoding.UTF8.GetString(mydatabuffer);
System.IO.File.WriteAllText(路径, html);
WebResponse res = req.GetResponse(); // GetResponse blocks until the response arrives
Stream ReceiveStream = res.GetResponseStream(); // Read the stream into a string
StreamReader sr = new StreamReader( ReceiveStream );
string resultstring = sr.ReadToEnd();