本帖最后由 php_fly 于 2014-6-29 23:41 编辑
post提交数据的时候,成功了,但提交的中文在网页上显示结果乱码。
抓到的数据包:
[C#] 纯文本查看 复制代码
POST /ajax/post.php?_method=AddOrder HTTP/1.1
Host: www.xxx.com
User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:30.0) Gecko/20100101 Firefox/30.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Length: 88
Content-Type: text/plain; charset=UTF-8
Connection: keep-alive
Pragma: no-cache
Cache-Control: no-cache
需要提交的数据如下:
keywords=中文会乱码
代码如下:
[C#] 纯文本查看 复制代码 HttpHelper http = new HttpHelper();
HttpItem item = new HttpItem();
HttpResult result;
item.URL = "http://www.xxx.com/ajax/post.php?_method=AddOrder";
item.Method = "post";
item.Encoding = Encoding.UTF8;
item.Cookie = this._cookie;
item.Postdata = "keywords=中文会乱码";
result = http.GetHtml(item);
第一直觉是编码问题,但是,尝试着使用其他的编码,结果还是乱码
[C#] 纯文本查看 复制代码 item.Postdata = Encoding.UTF8.GetString(Encoding.Default.GetBytes("keywords=中文会乱码"));
|