大致代码如下
procedure GetHttpFileThread.Execute;
var
temp,i,j,k,ALlPage:integer;
// idhttp1:TIdHTTP;
pageSong,PageDl,PageGeci,TempContent:AnsiString;
SingerID:integer;
SingerName:string;
SongDLAddress,TempSongDLAddress,geciDLAddress,SongName,DlName:string;
SongId:String;
F_TempSongName,F_TempGeCi,F_TempDL,TempSongName,TempGeCi,TempDL:String;
SongNameFile,GeCiFile,DlFile:TextFile;
TempPageSong:AnsiString;
begin
try
// Idhttp1:=Tidhttp.Create(nil);
begin
while (not Terminated)do
begin
EnterCriticalSection(CS);
if counter <total then
begin
counter:=counter+1;
temp:=Counter;
LeaveCriticalSection(CS);
end
else
begin
LeaveCriticalSection(CS);
exit;
end;
SingerName:=Form1.StringGrid4.Cells [1,temp];
SingerLianjie:=Form1.StringGrid4.Cells [2,temp];
SingerId:=StrToInt(Form1.StringGrid4.Cells [3,temp]);
lianjie:=SingerName+SingerLianjie+SingerId;
try
F_TempSongName:='X'+SIngerName+','+IntToStr(singerid)+','+'.txt';
TempSongName:=SingerName+','+IntToStr(singerid)+','+'.txt';
AssignFile(SongNameFile,F_TempSongName);
Rewrite(SongNameFile);
except
end;
temp_Data := TstringStream.Create('');
try
Now_lianjie:=lianjie;
httpcli1.URL:=Lianjie;
httpcli1.RcvdStream := temp_Data;
form1.CSObject1.SendMsg(csmWarning,inttostr(index)+','+Now_Lianjie);
httpcli1.Get ;
page:='';
page:=temp_data.DataString;
except
continue;
end;
Analyze(page);
end;
end;
Procedure GetHttpFileThread.Analyze(text:AnsiString);
var
i,k,TempNowStudentNumber,TempMostStudentNumber:integer;
studentname,StudentMail,StudentChinarenName:string;
begin
k:=pos('class=cr2lk>',line);
if k<>0 then
delete(line,1,k+11);
while (k<>0)do
begin
StudentName:=copy(line,1,pos('</a>',line) - 1);
k:=pos('class=cr2lk>',line);
delete(line,1,k+11);
StudentChinarenName:=copy(line,1,pos('</a>',line) - 1);
k:=pos('class=cr2>',line);
delete(line,1,k+9);
StudentMail:=copy(line,1,pos('</a>',line) - 1);
k:=pos('class=cr2lk>',line);
if k<>0 then
delete(line,1,k+11);
if goonid='' then
begin
// sleep(100);
Writeln(F,'1'+'@@@'+StudentName+'@@@');
end
else
begin
Append(f);
Writeln(F,'1'+'@@@'+StudentNameid);
Flush(f);
end;
end;
end;
end.