老问题没解决,新问题又来了,还是idhttp 你用TMemoryStream试试,或许是应为2010的string是unicode编码,d6还是ansi的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你怎么就断定是代码转换的问题呢? 在GET前面加下面一行试试看。IdHTTP1.Request.UserAgent:='Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)'; 不是这些问题,是因为返回的内容压缩了,返回实际内容如下:/**********************************************HTTP/1.1 200 OKDate: Thu, 06 Sep 2012 11:27:19 GMTContent-Type: text/html;charset=UTF-8Transfer-Encoding: chunkedConnection: keep-aliveVary: Accept-EncodingSet-Cookie: JSESSIONID=03CDFB6D0A3F939F665E8C1CAA999103; Path=/Server: N.WEBPROXY-1.20Expires: Thu, 06 Sep 2012 11:27:19 GMTCache-Control: max-age=0Content-Encoding: gzip15?***************************/要自己用gzip解压缩 procedure DecompressGZip(AInStream, AOutStream: TStream);procedure TDemoForm.DecompressGZip(AInStream, AOutStream: TStream);var pb1, pb2: Byte;begin AInStream.Seek(1, 0); AInStream.Read(pb1, 1); AInStream.Seek(2, 0); AInStream.Read(pb2, 1); AInStream.Position := 0; AOutStream.Position := 0; if (pb1 = $8B) and (pb2 = $8) then //gzip ZDecompressStream2(AInStream, AOutStream, 47) else AOutStream.CopyFrom(AInStream, AInStream.Size);end;自己去下个ZLibEx单元,里边有ZDecompressStream2函数 用不着这么费劲吧。你不是用 Indy 的 Http 吗在 Indy Misc 里有个 TIdCompressorZLib在IdHttp 里,指定属性 Compressor = 这个 TIdCompressorZLib全自动解码,嘿 http://my.csdn.net/my/code/detail/18338 另外:rocedure TForm2.Button1Click(Sender: TObject);var ResponseStream: TStringStream; i: integer; URL: string;begin ResponseStream := TStringstream.Create('', 936); IdHTTP1.Request.AcceptEncoding := 'identity'; URL := 'http://www.118100.cn/action/secweborder/isCTMobile.do?mobile=' + edit1.Text; IdHTTP1.Get(URL, ResponseStream); Memo1.Lines.Add('-------------------------'); Memo1.Lines.Add(URL); // 这里不再需要对UTF8解码,因为它本来就不是UTF8 Memo1.Lines.Add(ResponseStream.DataString); Freeandnil(ResponseStream);end; 谢谢大家了,从delphi改成PHP了 楼上的真搞笑~!--- 跟人签名 ----------------高价收药、收药、北京收药:http://www.woshouyao.com/index.php Format(' %.2x', [P[I]]) 啥意思? 精确的屏幕取词的源码,高分相送,请高手帮忙. 动态创建控件的标签问题,在线等 程序员身体容易出什么毛病?怎样避免? ADO批量更新主從表時只更新一筆記錄,為何(如果沒有建立主從關係就可以批量更新)請高手指點一下!!!! 自己的软件完成!祝贺,跟着有分!!!!各位也可以下载看看!!! 哪里有向管家婆一样的打印管理器源码啊,高分相送! delphi编辑器界面设置问题 ADOQuery中执行SQL语句如何使用DELPHI函数。 怎样更改查询到的数据? 求救帮修改RealICQ客户端D源码中的升级模块注解掉或者删除掉即可 求帮忙解释下代码
/**********************************************
HTTP/1.1 200 OK
Date: Thu, 06 Sep 2012 11:27:19 GMT
Content-Type: text/html;charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
Set-Cookie: JSESSIONID=03CDFB6D0A3F939F665E8C1CAA999103; Path=/
Server: N.WEBPROXY-1.20
Expires: Thu, 06 Sep 2012 11:27:19 GMT
Cache-Control: max-age=0
Content-Encoding: gzip15
?***************************/
要自己用gzip解压缩
var
pb1, pb2: Byte;
begin
AInStream.Seek(1, 0);
AInStream.Read(pb1, 1);
AInStream.Seek(2, 0);
AInStream.Read(pb2, 1);
AInStream.Position := 0;
AOutStream.Position := 0;
if (pb1 = $8B) and (pb2 = $8) then //gzip
ZDecompressStream2(AInStream, AOutStream, 47)
else
AOutStream.CopyFrom(AInStream, AInStream.Size);
end;自己去下个ZLibEx单元,里边有ZDecompressStream2函数
你不是用 Indy 的 Http 吗
在 Indy Misc 里有个 TIdCompressorZLib
在IdHttp 里,指定属性 Compressor = 这个 TIdCompressorZLib
全自动解码,嘿
rocedure TForm2.Button1Click(Sender: TObject);
var
ResponseStream: TStringStream;
i: integer;
URL: string;
begin
ResponseStream := TStringstream.Create('', 936);
IdHTTP1.Request.AcceptEncoding := 'identity';
URL := 'http://www.118100.cn/action/secweborder/isCTMobile.do?mobile=' + edit1.Text;
IdHTTP1.Get(URL, ResponseStream);
Memo1.Lines.Add('-------------------------');
Memo1.Lines.Add(URL);
// 这里不再需要对UTF8解码,因为它本来就不是UTF8
Memo1.Lines.Add(ResponseStream.DataString);
Freeandnil(ResponseStream);
end;
高价收药、收药、北京收药:
http://www.woshouyao.com/index.php