【发布时间】:2014-08-24 12:54:21
【问题描述】:
我正在尝试从网页中获取 HTML。我已经获取并设置了 cookie。 这是请求头的一部分:
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: <.......URL......>
Cookie: ASP.NET_SessionId=rk2tt31jgxyvszna1slzthho; .ASPXAUT=<.....token......>
Connection: keep-alive
这是 Live HTTP Headers 给出的良好响应的转储标头:
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Expires: -1
Vary: Accept-Encoding
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sun, 24 Aug 2014 12:48:36 GMT
Content-Length: 13400
我正在使用StreamReader(response.GetResponseStream(),Encoding.UTF8) 从流中读取数据。
问题是StreamReader.ReadToEnd()返回了很多符号而不是HTML代码:
�\b\0\0\0\0\0\0�\a`I�%&/m�{J�J��t
【问题讨论】:
标签: html asp.net streamreader httpwebresponse