English > Scripts and Templates

Project Allocine script

<< < (3/11) > >>

pra15:
Ok thanks,

I change CODE_PAGE in 65001 Unicode utf 8, it's good for the moment.

pra15:
Change some errors exeptions in parsesearchresults

Ivek23:

--- Quote from: pra15 on February 10, 2015, 12:38:17 am ---Change some errors exeptions in parsesearchresults
--- End quote ---

Thanks to the new version, but now I procedure ParseSearchResults almost 99% of search this code
--- Code: ---procedure 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;
CurPos := PosFrom('<div class="vmargin10t">',HTML,CurPos);
//Addresse Thumbnail :
CurPos := PosFrom('src=',HTML,CurPos)+5;
EndPos := PosFrom('alt=',HTML,CurPos)-2;
ThumbURL := Trim(Copy(HTML,CurPos,EndPos-CurPos));
//Addresse page Film :
CurPos := PosFrom('<a href=',HTML,CurPos)+9;
while (curPos > 0) AND (curPos < PosFrom('>1</em></li><li', HTML, endPos)) do begin
//while (curPos > 0) AND (curPos < PosFrom('<button class="buttonform" type="submit">Rechercher</button>', HTML, endPos)) do begin
EndPos := PosFrom('.html',HTML,CurPos)+5;
MovieURL := BASE_URL + Trim(Copy(HTML,CurPos,EndPos-CurPos));
Logmessage('MovieURL : ' + MovieURL);
//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>',' / ',True,True,True);
LogMessage('Titre Recherche: ' + Title);
//Année :
CurPos := PosFrom('<span class="fs11">',HTML,EndPos);
if Curpos > 0 then begin
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('alt=',HTML,CurPos)-2;
ThumbURL := Trim(Copy(HTML,CurPos,EndPos-CurPos));
LogMessage('ThumbURL :' + ThumbURL);

CurPos := PosFrom('<a href=',HTML,CurPos)+9;
end;

End;
--- End code ---
can not find the results, while me with this code
--- Code: ---procedure 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;
CurPos := PosFrom('<div class="vmargin10t">',HTML,CurPos);
//Addresse Thumbnail :
CurPos := PosFrom('src='+#39,HTML,CurPos);
EndPos := PosFrom('alt='+#39,HTML,CurPos);
ThumbURL := Trim(Copy(HTML,CurPos+5,EndPos-CurPos-7));
//Addresse page Film :
CurPos := PosFrom('<a href=',HTML,CurPos)+9;
//while (curPos > 0) AND (curPos < PosFrom('>1</em></li><li', HTML, endPos)) do begin
while (curPos > 0) AND (curPos < PosFrom('<button class="buttonform" type="submit">Rechercher</button>', HTML, endPos)) do begin
EndPos := PosFrom('.html',HTML,CurPos)+5;
MovieURL := BASE_URL + Trim(Copy(HTML,CurPos,EndPos-CurPos));
Logmessage('MovieURL : ' + MovieURL);
//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>',' / ',True,True,True);
LogMessage('Titre Recherche: ' + Title);
//Année :
CurPos := PosFrom('<span class="fs11">',HTML,EndPos);
if Curpos > 0 then begin
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='+#39,HTML,CurPos);
EndPos := PosFrom('alt='+#39,HTML,CurPos);
ThumbURL := Trim(Copy(HTML,CurPos+5,EndPos-CurPos-7));
LogMessage('ThumbURL :' + ThumbURL);

CurPos := PosFrom('<a href=',HTML,CurPos)+9;
end;

End;
--- End code ---
in 99% it finds search results for movie titles.

I think it will be necessary to keep this below ParseSearchResults procedure, because this really works, at least for me it works on about 20 movie titles that I've tested.

Even in Nationalité Allociné, Note Presse and Note Spectateurs code is a lot of false data transfers, add some movie titles with errors in data transmission:

Note Presse

American Pie Presents Band Camp
American Pie Presents: Beta House
American Pie Presents: The Book of Love
American Pie Presents: The Naked Mile

Apaches Rifles
http://www.allocine.fr/film/fichefilm_gen_cfilm=44222.html


Note Presse and Note Spectateurs

Canciones de amor en Lolita's club
http://www.allocine.fr/film/fichefilm_gen_cfilm=134873.html

Casualties of Love: The Long Island Lolita Story
http://www.allocine.fr/film/fichefilm_gen_cfilm=211875.html

Children of Invention
http://www.allocine.fr/film/fichefilm_gen_cfilm=142444.html

Lota
http://www.allocine.fr/film/fichefilm_gen_cfilm=230014.html


Nationalité Allociné

The Shooting of Dan McGoo
http://www.allocine.fr/film/fichefilm_gen_cfilm=170340.html

The Shooting of Thomas Hurndall
http://www.allocine.fr/film/fichefilm_gen_cfilm=178138.html

Who - The Kids Are Alright
http://www.allocine.fr/film/fichefilm_gen_cfilm=169939.html

pra15:
Thanks, i'll see that, but for the moment i'm not sure of the structure of my script. Just one script, not two. I look up the allmovie script for ideas. It's not simple with several page and especially for image (several images in several pages).

Once the structure will be good, i'll can concentrate for search data.

pra15:
Sorry, i'm totally blocked;
i've tried to make an other script (only one) based on allmovie.

My problem is with the photos;
There is a principal page with list of all image, then we must (for each image) go to an other page to got the link of the image.
In My script i go to the first page and put the links of seconds pages in a array.

But during execution of the script i can't get to the second page, the mode change to ModePrephoto (Principal page where is the list of the image) to mode finished.

I try to put condition in getdownloadURL, or in NextMode but it seems doesn't work.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version