Home > Back-end >  About the download list -- -- -- -- -- -- -- -- -- -- -- how to design this structure?
About the download list -- -- -- -- -- -- -- -- -- -- -- how to design this structure?

Time:09-27

Is like this, I want to use Idhttp download a website links to all documents, but the structure of how to design good?

I feel I have a question that the following structure, and efficiency is also have a question, this structure is how to design good?

Prawns help please, thank you...

/download/cycle, the whole site HTML code 
Procedure TTestForm. Button8Click (Sender: TObject);
Var
AddrList: TStringList;//url list
CurLink LinkSource: String;//links page source code
Ts1, ts2: TStringList;
I, j, k: Integer;
The begin
//1. Obtained from the first portal site source code
CurSite:='http://www.XXXX.com';//mark the current url, which is used to address standardization, tail without/
LinkSource:=PageSource (CurSite);

Try
//2. The analysis of the source code, the initial link
AddrList:=TStringList. Create;
Ts1:==TStringList. Create;
Ts2:==TStringList. Create;

AddrList:=PageLink (LinkSource, 'href [^ \ s] *');
K:=0;
//ShowMessage (ts1. GetText);

//3. Cycle each link address, until all of the execution of the
While AddrList. Count<0 do
The begin
LinkSource:=PageSource (AddrList. Strings [k]);//link to the source code, PageSource for access to the source function, HTM string
Ts1:=PageLink (LinkSource, 'href [^ \ s] *');//the source code to jilt links, PageLink for formal expression, obtaining all hyperlinks Stringlist data list
//add links to the list
If LinkSource<> "' then
The begin
//release ts1, added to the array AddrList
For j:=0 to ts1. Do the Count - 1
The begin
If AddrList. IndexOf (Trim (ts1. Strings [I])) & lt; 0 then//when does not exist, add
AddrList. Add (Trim (ts1. Strings [I]));
end;

end;
//save the file
Ts2. Add (LinkSource);
Ts2. SaveToFile (k + 'HTM');
//delete the current record after execution
AddrList. Delete (k);
Inc (k);
end;
The finally
AddrList. Free;
Ts1. Free;
Ts2. Free;
end;

end;

CodePudding user response:

Have no passing brother...

CodePudding user response:

Structure do not have what problem, use multithreading promote efficiency
  • Related