小编syk*_*ing的帖子

如果返回内容是Transfer-Encoding:chunked,如何从HttpWebResponse获取完整内容?

我正在编写一个从其他网站下载html页面的程序.我发现一个问题,对于某些特定的网站,我无法获得完整的HTML代码.我只能获得部分内容.有这个问题的服务器在"Transfer-Encoding:chunked"中发送数据,恐怕这就是问题的原因.

这是服务器返回的头信息:

Transfer-Encoding: chunked
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Content-Type: text/html; charset=UTF-8
Date: Sun, 11 Sep 2011 09:46:23 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Server: nginx/1.0.6
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
HttpWebResponse response;
CookieContainer cookie = new CookieContainer();
request.CookieContainer = cookie;
request.AllowAutoRedirect = true;
request.KeepAlive = true;
request.UserAgent =
    @"Mozilla/5.0 (Windows NT 6.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2 FirePHP/0.6";
request.Accept = @"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
string html = string.Empty;
response = request.GetResponse() as HttpWebResponse;

using (StreamReader …
Run Code Online (Sandbox Code Playgroud)

.net c# web

14
推荐指数
2
解决办法
2万
查看次数

为什么我的页面无法显示é,而是显示 ?

我在html中将页面编码设置为utf-8:

meta http-equiv ="content-type"content ="application/xhtml + xml; charset = UTF-8"

在HTTP标题中,我有:

Content-Type text/html; 字符集= UTF-8

为什么不能正确显示é?

谢谢

更新:数据包含从互联网抓取的'é',抓取工具是用Microsoft .Net编写的.我使用Mysql .Net Connector来连接mysql.

显示'é'的页面是用PHP编写的.

html character-encoding

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

.net ×1

c# ×1

character-encoding ×1

html ×1

web ×1