timer过程内的idhttp.get第二次运行时,取不到数据??? 本帖最后由 l2walker 于 2010-04-28 09:49:39 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 运行过程也正常,没出现什么问题 ... 可oHtml值始终为空,第一次oHtml值正常 ... 之后,第二次 .. 第三次 ... 第N次,oHtml值均为空;但我用HTTPLook监视时,aIdHTTP.Get('http://www.xxx.com/ooo/?page='+IntToStr(eax),ResponseGet) 每次都正常取得值了的;可程序中的 oHtml 值始终为空 ... 不知道哪出错了.. 一般来说。GET后需要disconnect .POST 最好不要disconnect 加了aIdHttp.Disconnect后,我每个.Get()后都加了,问题依旧 .. 晕是不是我把aIdHttp.Disconnect位置加错了呢?我刚学一点点delphi,非coder;补充,其中后面代码中还用到 aIdHTTP.get(...) 和 aIdHTTP.post(...) ,如下:procedure TForm1.Timer1Timer(Sender: TObject);var aPostData,eUrlList,eeUrlList,atmp:TStringList; aResponseData:TStringStream; oHtml,tmp,eID,eUrl,eTitle:string; ResponseGet:TStringStream; ea,et,eax:integer; FirstTickCount,MSecs, Now: Longint;beginTimer1.Enabled:=false;atmp:=TStringList.Create;eUrlList:=TStringList.Create;eeUrlList:=TStringList.Create;for eax := 1 to 9 do begin if Assigned(ResponseGet) then FreeAndNil(ResponseGet); ResponseGet:=TStringStream.Create(''); aIdHTTP.Request.Host:='http://www.xxx.com/ooo/'; if eax=1 then begin aIdHTTP.Request.Referer:='http://www.xxx.com/'; //aIdHTTP是全局变量 aIdHTTP.Get('http://www.xxx.com/ooo/',ResponseGet); end else begin aIdHTTP.Request.Referer:='http://www.xxx.com/ooo/?page='+IntToStr(eax-1); aIdHTTP.Get('http://www.xxx.com/ooo/?page='+IntToStr(eax),ResponseGet); end; oHtml:= UTF8Decode(ResponseGet.DataString); showmessage(oHtml); // 这里timer运行第二次时,oHtml为空; .................... aIdHTTP.get(...) ; // 这里这里 .................... aIdHTTP.post(...) ; // 这里这里 .................... end; Timer1.Enabled:=true;end; 加了aIdHttp.Disconnect后,我每个.Get()后都加了????是不是位置不对呀,之后加,那不还是什么都没有吗,Get之前加 前后,我都试了 ... 还是不行;放在后面,数据不是已经get到 ResponseGet 中了吗? 结了,是IDHttp的问题,最终,我把它Freeandnil(aIDHttp)掉再create后,就正常了; delphi自带的控件都提供源码吗?可以修改控件的源码吗? 请问各位高手,为什么焦点在控件上,而光标不见了,向上面又可以输入内容? 我只会用ADOquery,不会用Dataset,有没有Dataset的教程啊! Delphi怎么样来复制一个表格! 关于sqlserver和delphi时间查询的一个bug! 关于重绘窗体的问题,100分,求救 有关DELPHI的web编程问题 RZSplitter分割控件使用问题 Delphi和数据库高手(或爱好者)提供我Oicq号吧,不见不散! 关于DBGRID控件?? 请问XlGrid打印的方法是什么? delphi中关于线程的问题,急!!
可程序中的 oHtml 值始终为空 ... 不知道哪出错了..
加了aIdHttp.Disconnect后,我每个.Get()后都加了,问题依旧 .. 晕
是不是我把aIdHttp.Disconnect位置加错了呢?我刚学一点点delphi,非coder;补充,其中后面代码中还用到 aIdHTTP.get(...) 和 aIdHTTP.post(...) ,如下:procedure TForm1.Timer1Timer(Sender: TObject);
var
aPostData,eUrlList,eeUrlList,atmp:TStringList;
aResponseData:TStringStream;
oHtml,tmp,eID,eUrl,eTitle:string;
ResponseGet:TStringStream;
ea,et,eax:integer;
FirstTickCount,MSecs, Now: Longint;beginTimer1.Enabled:=false;atmp:=TStringList.Create;
eUrlList:=TStringList.Create;
eeUrlList:=TStringList.Create;for eax := 1 to 9 do
begin if Assigned(ResponseGet) then FreeAndNil(ResponseGet);
ResponseGet:=TStringStream.Create('');
aIdHTTP.Request.Host:='http://www.xxx.com/ooo/';
if eax=1 then
begin
aIdHTTP.Request.Referer:='http://www.xxx.com/'; //aIdHTTP是全局变量
aIdHTTP.Get('http://www.xxx.com/ooo/',ResponseGet);
end
else
begin
aIdHTTP.Request.Referer:='http://www.xxx.com/ooo/?page='+IntToStr(eax-1);
aIdHTTP.Get('http://www.xxx.com/ooo/?page='+IntToStr(eax),ResponseGet);
end; oHtml:= UTF8Decode(ResponseGet.DataString);
showmessage(oHtml); // 这里timer运行第二次时,oHtml为空;
....................
aIdHTTP.get(...) ; // 这里这里
....................
aIdHTTP.post(...) ; // 这里这里
....................
end; Timer1.Enabled:=true;
end;
放在后面,数据不是已经get到 ResponseGet 中了吗?