1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
function Donnecequisuis_multi(URL : string; debut:string;fin:string;maxinstance:integer):Tstringarray;
var HTTP : TIdHTTP;
Content, Link : string;
Positiondeb : integer;
Positionfin : integer;
longueur : integer;
i:integer ;//Pour le compteur dans la boucle qui trouve les planetes
double_i : integer;
begin
HTTP := TIdHTTP.Create(nil);
try
//On recupere la page
Content := HTTP.Get(URL);
//On cherche les instances ;)
Positiondeb := 0;
Positionfin := 0;
i:=1;
while true do
begin
//On trouve le debut du truc
Positiondeb := PosEx(debut, Content, Positiondeb+length(debut));
//Si on trouve pas le mot, on laisse tombé
if Positiondeb = 0 then break;
//On cherche la fin de la chaine
PositionFin := PosEx(fin, Content, Positiondeb++length(debut));
longueur := PositionFin - (PositionDeb+length(debut));
//On copy le mot cherché dans la variable link
link := copy(Content, PositionDeb+length(debut), longueur);
//On renvoie le resultat
showmessage('Sav'+link);
Result[i] := link;
showmessage('Verif');
if maxinstance > i then break;
i := i +1 ;
end;
finally
HTTP.Free;
end;
end; |
Partager