Get data from specified URI using WebRequest and WebResponse(读取网页数据并存入对应html文档)

  WebRequest is a request to send messages to a URI to send messages, URI as a parameter is passed to Create () method. And we take WebResponse class as data obtained from the server. The method WebRequest.GetResponse () will indeed send the request to the Web server, create a Response object,  and then check the returned data. Like the WebClient object, you can get a stream of data, however, the data flow is obtained by WebResponse.GetResponseStream () method.

  Here is a smple to show you how to get data from URI and save as a html file:

Get Data From Uri

  

  Note this: If we use StreamWriter to write directly, we will get some garbled characters in the html file. Of course that's the encoding problem.

 

Go to my home page for more posts

你可能感兴趣的:(response)