idHttp1怎么初始化啊?初始化成什么?谢谢谢谢!

解决方案 »

  1.   

    with TIdHttp.Create(nil) do
    try
      HtmlContent := Get(AURL);
    finally
      Free;
    end;
      

  2.   

    function CreateHttpObj(sType:String;AOwner:Tcomponent):TidHttp;
    var objHttp:TidHttp;
    Begin
    Result:=nil;
    objHttp:=nil;
    try
      objHttp:=TidHttp.Create(AOwner);
      with ConnectionSet do
      begin
        if  (cUsesProxy= true) then
         begin
            with objHttp.Request do
              begin
                ProxyServer:=cProxyIP;
                ProxyPort:=StrToIntDef(cProxyPort,80);
                ProxyUsername:=cProxyUserName;
                ProxyPassword:=cProxyUserPassWord;
              end
         end;
      end;
      //代理设置完毕
      //设置useragent
      objHttp.Request.UserAgent:=UserAgentStr;
      Result:=objHttp;
    finally
      objHttp:=nil;
    end;
    End;