26-12-2016, 08:34 PM
للاسف انا مجربه قبل هذا لكن يعطيني نفس السطر الاول مكرر لذلك استعملت
for in loop المكافئة ل foreach ولكن لا جدوى انظر الصورة
http://up.dev-point.com/uploads1/f20026c975621.jpg
هذا الكود كامل
procedure TForm1.Button1Click(Sender: TObject);
var
Lst : TListItem;
http :TIdHTTP;
reg: IRegExp2;
MatchCollection: IMatchCollection2;
Match1: IMatch2;
match: ISubMatches;
txt
tring;
i : integer;
begin
reg := CoRegExp.Create;
reg.Global := True;
reg.IgnoreCase:=true;
reg.Pattern := '<a class="internal-link" href="http://filehippo.com.*?title="([a-z0-9\s!.]+)">[\S\s]+?<img src="(.*?.png)"/>';
http:=TIdHTTP.Create(nil);
txt:= http.Get ('http://filehippo.com/fr/software/antimalware/');
http.Request.UserAgent:='Mozilla/5.0 (Windows NT 6.1; rv:48.0) Gecko/20100101 Firefox/48.0';
MatchCollection := reg.Execute(txt) as IMatchCollection2;
if MatchCollection.Count = 0 then exit;
Match1 := MatchCollection.Item[0] as IMatch2;
match := Match1.SubMatches as ISubMatches;
begin
begin
for i:=0 to Matchcollection.count-1 do
begin
lst:=listview1.Items.Add;;
lst.Caption:=match[0];
lst.SubItems.Add(match[1]);
end;
IdHTTP1.Free;
end;
end;
end;
end.
for in loop المكافئة ل foreach ولكن لا جدوى انظر الصورة
http://up.dev-point.com/uploads1/f20026c975621.jpg
هذا الكود كامل
procedure TForm1.Button1Click(Sender: TObject);
var
Lst : TListItem;
http :TIdHTTP;
reg: IRegExp2;
MatchCollection: IMatchCollection2;
Match1: IMatch2;
match: ISubMatches;
txt
tring;i : integer;
begin
reg := CoRegExp.Create;
reg.Global := True;
reg.IgnoreCase:=true;
reg.Pattern := '<a class="internal-link" href="http://filehippo.com.*?title="([a-z0-9\s!.]+)">[\S\s]+?<img src="(.*?.png)"/>';
http:=TIdHTTP.Create(nil);
txt:= http.Get ('http://filehippo.com/fr/software/antimalware/');
http.Request.UserAgent:='Mozilla/5.0 (Windows NT 6.1; rv:48.0) Gecko/20100101 Firefox/48.0';
MatchCollection := reg.Execute(txt) as IMatchCollection2;
if MatchCollection.Count = 0 then exit;
Match1 := MatchCollection.Item[0] as IMatch2;
match := Match1.SubMatches as ISubMatches;
begin
begin
for i:=0 to Matchcollection.count-1 do
begin
lst:=listview1.Items.Add;;
lst.Caption:=match[0];
lst.SubItems.Add(match[1]);
end;
IdHTTP1.Free;
end;
end;
end;
end.

