with TIdHttp.Create(nil) do try HtmlContent := Get(AURL); finally Free; end;
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;
try
HtmlContent := Get(AURL);
finally
Free;
end;
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;