我想使用idhttp循环获得网页代码,多个网络地址分行放在memo1中,  for i := 0 to memo1.lines.count -1 do
    begin
      Delay(4000);
      try
        memo2.Lines.Add('@@@@'+inttostr(i)+'@@@@' +IDhttp1.Get(memo1.lines.string[i]);
      execpt
        //showmessage('异常')      end;
    end;出现异常的原因可能是网络线路不好,我想发生异常继续再次获得异常行的网页代码.
能发现这个异常,但是如果有异常发生将丢失异常行的网页代码,请教如何能自动按顺序获得memo1中各行的网页代码到memo2中呢?

解决方案 »

  1.   

      for i := 0 to memo1.lines.count -1 do
      begin
          Delay(4000);
          got := False;
          errorcount := 0;
          while not got do
          begin
            try
              memo2.Lines.Add('@@@@'+inttostr(i)+'@@@@' +IDhttp1.Get(memo1.lines.string[i]);
              got := True;
            except
              Inc(errorcount);
              if errorcount > 2 then //重试超过3次跳出
                break;
              //showmessage('异常')
            end;
          end;
      end;