Try this codeprocedure ParseSearchResults(HTML: string);
Var
CurPos, EndPos, EndSearch, nbResult, PosEssai1, PosEssai2 : Integer;
Year, MovieURL, ThumbURL, Title : String;
Begin
NbResult := 0;
CurPos := Pos('Films</h2>',HTML);
If CurPos < 1 then
Exit;
//Addresse Thumbnail :
CurPos := PosFrom('src=',HTML,CurPos)+5;
EndPos := PosFrom('.jpg',HTML,CurPos)+4;
ThumbURL := Trim(Copy(HTML,CurPos,EndPos-CurPos));
//Addresse page Film :
//CurPos := PosFrom('<a href=',HTML,EndPos);
CurPos := PosFrom('<a href=',HTML,CurPos);
//while curPos > 0 do begin
while (curPos > 0) AND (curPos < PosFrom('<button class="buttonform" type="submit">Rechercher</button>', HTML, endPos)) do begin
EndPos := PosFrom('.html',HTML,CurPos);
MovieURL := BASE_URL + Trim(Copy(HTML,CurPos+9,EndPos-CurPos-4));
//Nom Film :
CurPos := PosFrom('>',HTML,EndPos)+1;
EndPos := PosFrom('<br />',HTML,CurPos);
Title := Copy(HTML,CurPos,EndPos-CurPos);
Title := StringReplace(Title,'<b>','',True,True,True);
Title := StringReplace(Title,'</b>','',True,True,True);
Title := StringReplace(Title,'</a>',' (fr) / ',True,True,True);
LogMessage('Titre Recherche: ' + Title);
//Année :
CurPos := PosFrom('<span class="fs11">',HTML,EndPos);
if Curpos > 0 then begin
//Curpos := Curpos + 19;
//EndPos := PosFrom('<br />',HTML,CurPos);
//Year := Copy(HTML,CurPos,EndPos-CurPos);
Year := TextBetween(HTML, '<span class="fs11">', '<br />', True, CurPos);
LogMessage('Annee: ' + Year);
end else begin
Year := '';
curPos := endPos;
end;
//Ajout du film dans la liste des résultats :
AddSearchResult(Title,'', Year, MovieURL, ThumbURL);
//Addresse Thumbnail :
CurPos := PosFrom('src=',HTML,CurPos)+5;
EndPos := PosFrom('.jpg',HTML,CurPos)+4;
ThumbURL := Trim(Copy(HTML,CurPos,EndPos-CurPos));
CurPos := PosFrom('<a href=',HTML,CurPos);
end;
End;
it should work, at least for me it worked.