|
为什么在winform里用HttpWebRequest请求一个网页之后,Response返回的html文本不完整呢?
怎么会这样呢?在浏览器里面打开都是完整的啊,是我读取Response.GetResponsStream()有问题吗?- request = (HttpWebRequest)WebRequest.Create(url1);
- request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
- request.CookieContainer = cookies;
- request.UserAgent = "Mozilla/5.0 (Windows NT 6.1; rv:22.0) Gecko/20100101 Firefox/22.0";
- request.Referer = url1;
- response = (HttpWebResponse)request.GetResponse();
-
- StreamReader read = new StreamReader(response.GetResponseStream(), Encoding.GetEncoding("utf-8"));
- string resultstr = read.ReadToEnd();
复制代码 |
|