function TMyThreads.Lunch: Boolean;
...
begin
Result:= False;
//init components
IdHTTP:= TIdHTTP.Create(
nil);
IdCookieManager:= TIdCookieManager.Create(
nil);
PostDataStream := TStringStream.Create('
');
ParamData := TStringStream.Create('
');
//settings
IdHTTP.AllowCookies:= True;
IdHTTP.CookieManager:= IdCookieManager;
IdHTTP.HandleRedirects:= True;
IdHTTP.Request.ContentType:= '
application/x-www-form-urlencoded';
IdHTTP.Request.Connection:= '
Keep-Alive';
IdHTTP.ConnectTimeout:= 10000;
IdHTTP.Request.UserAgent:= '
..';
Source:= '
';
Source:= Get('
...');
if SmartPos('
...', Source, False, 1, True) > 0
then
begin
Source:= '
';
Source:= Get('
...');
if SmartPos('
...', Source, False, 1, True) > 0
then
begin
...
end;
end;
Source:= '
';
Source:= Get('
...');
if SmartPos('
...', Source, False, 1, True) > 0
then
begin
Source:= '
';
Source:= Get('
...');
if SmartPos('
...', Source, False, 1, True) > 0
then
begin
...
end;
end;
Source:= '
';
Source:= Get('
...');
if SmartPos('
...', Source, False, 1, True) > 0
then
begin
Source:= '
';
Source:= Get('
...');
if SmartPos('
...', Source, False, 1, True) > 0
then
begin
...
end;
end;
...
// usw
FreeAndNil(ParamData);
FreeAndNil(PostDataStream);
FreeAndNil(IdCookieManager);
FreeAndNil(IdHTTP);
Result:= True;
end;
function TMyThreads.Get(
Url:
String):
String;
begin
try
Result:= IdHTTP.Get(
Url);
except
FStatus:= '
error';
Synchronize(UpdateLVCaption);
Result:= '
';
end;
end;
function TMyThreads.Post(
Url, Params:
String):
String;
begin
ParamData.WriteString(Params);
try
IdHTTP.Post(
Url, ParamData, PostDataStream);
Result:= PostDataStream.DataString;
except
FStatus:= '
error';
Synchronize(UpdateLVCaption);
Result:= '
';
end;
ParamData.Size:= 0;
PostDataStream.Size:= 0;
end;