Page 1 of 1

[REL] [ITA] Extr. informations from Libreria.Universitaria

Posted: 2009-09-19 05:48:36
by fulvio53s03
Ecco: (Here you are:)

Code: Select all

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=
Title=Libreria Universitaria.IT.ifs
Description=
Site=
Language=IT
Version=
Requires=3.5.1
Comments=
License=
GetInfo=1

[Options]

***************************************************)

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=
Title=Libreria Universitaria
Description=
Site=
Language=?
Version=
Requires=3.5.0
Comments=
License=
GetInfo=0

[Options]

***************************************************)

program libri;
uses
  StringUtils1;

var
  MovieName: string;
  TheMovieAddress: string;
  UrlSearch, InitSearch, EndSearch: string;
  comm: String;
const
  crlf = #13#10;                        // carriage return/line feed

procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr: integer;
  BeginPos: integer;
begin
  Page := TStringList.Create;
//ex  Page.Text := GetPage(Address);
  Page.Text := GetPage(Address);
  SetField(fieldURL, Address);
  LineNr := FindLine('class="small_font">Risultati per la tua ricerca', Page, 0);
  if LineNr = -1 then
  begin
    SetField(fieldURL, Address);
    AnalyzeMoviePage(Page);
  end
  else
  begin
    PickTreeClear;
    AddMoviesTitles(Page);
    if TheMovieAddress='' then
    begin
      if PickTreeExec(Address) then AnalyzePage(Address);
    end
    else
    begin
      SetField(fieldURL, MovieAddress);
      Page.Text := GetPage(Address); //Page.Text := GetPage(TheMovieAddress);
      AnalyzeMoviePage(Page);
    end;
  end;
  Page.Free;
end;

procedure AnalyzeMoviePage(Page: TStringList);    //estrae campi dalla pagina del libro scelto
var
  SaveLine, Line, Value, PreviousLine, NomeHtml, sTemp: string;
  LineNr,PrevLineNr, BeginPos, EndPos, Field: Integer;
  BeginChar, EndChar: string;
  SaveCommento, Commento: string;
  BeginLineNr, endLineNr: Integer;

begin
// Picture import            <table width="100%" cellpadding="8" border="0">
    LineNr := FindLine('<table width="100%" cellpadding="8" border="0">', Page, 0);
    Line := Page.GetString(LineNr);
    Line := TextBetween(Line, 'src="', '" height="240"');   // Extract the picture URL from "Page"
  if Line <> '' then   // If "Value" now contains picture URL then..
     GetPicture(Line);   // .. download and save picture

  LineNr := FindLine('<h3 class="product_section_title">Descrizione</h3>', Page, 0);         // param. 1
  if LineNr <> -1 then
   begin
//     LineNr := LineNr + 1;
     Line := Page.GetString(LineNr);
     saveLine := Line;
//     setfield(FieldComments, Line);   // cancellare poi
     Line := TextBetween(Line, '<div class="product_text" >', '</div>');    //trama     param. 2
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     setfield(FieldDescription, Line);

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Traduttore:</span>', '</span>'); // estrae Traduttore   param. 3
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        Line := 'Traduttore: ' + Line;
        setfield(FieldActors, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Editore:</span>', '</span>'); // estrae Editore   param. 3
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        Line := 'Editore: ' + Line;
        setfield(FieldProducer, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Data di Pubblicazione:</span>', '</span>'); // estrae Pubblicazione
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        setfield(FieldYear, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Collana:</span>', '</span>'); // estrae Collana   param. 3
     Line := TextBetween(Line, 'title="', '"');                                           // estrae Collana   param. 3
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        Line := 'Collana: ' + Line;
        setfield(Fieldcategory, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">ISBN:</span>', '</span>'); // estrae ISBN
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        Line := 'ISBN: ' + Line;
        setfield(FieldVideoFormat, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">ISBN-13:</span>', '</span>'); // estraeISBN13
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        Line := 'ISBN13: ' + Line;
        setfield(FieldAudioFormat, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Pagine:</span>', '</span>'); // estrae n.pagine
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     setfield(FieldLength, Line);

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Titolo:</span>', '</span>'); // estrae Titolo  param. 4
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     setfield(FieldTranslatedTitle, Line);

     LineNr := FindLine('<h2 class="product_text"', Page, 0);
     Line := Page.GetString(LineNr);
     Line := TextBetween(Line, 'title="', '"'); // estrae Autore
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     setfield(FieldDirector, Line);

     LineNr := FindLine('<br /><table border=0 cellspacing="12">', Page, 0);    // inizio estrazione commenti
     Line := Page.GetString(LineNr);
     Line := TextBetween(Line, 'title="', '"'); // estrae Autore
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     setfield(FieldDirector, Line);
//********************************* inizio aggiunta relativa ai commenti ******************************
     BeginLineNr := FindLine('<br /><table border=0 cellspacing="12">', Page, 0);              // inizio estrazione commenti
     EndLineNr   := FindLine('</table>', Page, BeginLinenr);    // fine estrazione commenti
     Line := '';
     While BeginLineNr <= EndLineNr do
        begin
        Line := Line + Page.GetString(BeginLineNr);    // inizio estrazione commenti
        beginLineNr := BeginLineNr + 1;
        end;

     SaveCommento := '';
     Commento := '*';
     While Commento <> '' do
        begin
        BeginChar := 'border="0" > <b>';
        EndChar   := '<br />';
        Commento := TextBetween(Line, BeginChar, EndChar); // estrae commento succinto
        Commento := Commento + EndChar;
        EndPos := Pos(Line, EndChar);
        delete(line, 0, EndPos);
        HTMLRemoveTags(Commento);
        HTMLDecode(Commento);
//        Commento := Fulltrim(Commento);
        SaveCommento := SaveCommento + Commento + ' ';

        BeginChar := '<br />';
        EndChar   := '<b>';
        Commento := TextBetween(Line, BeginChar, EndChar); // estrae autore del commento;
        Commento := Commento + EndChar;
        EndPos := Pos(Line, EndChar);
        delete(line, 0, EndPos);
        HTMLRemoveTags(Commento);
        HTMLDecode(Commento);
//        Commento := Fulltrim(Commento);
        SaveCommento := SaveCommento + Commento + ' - ';

        BeginChar := 'leggi tutte le sue recensioni</a><br /><br /><font color="#67b00e">';   // estrae commento esteso
        EndChar   := '<font color=';
        Commento := TextBetween(Line, BeginChar, EndChar); // estrae commento succinto
        EndPos := Pos(Line, EndChar) + length(EndChar);
        delete(line, 0, EndPos);
        HTMLRemoveTags(Commento);
        HTMLDecode(Commento);
        Commento := Fulltrim(Commento);
        SaveCommento := SaveCommento + Commento + crlf;
        end;
     
     setfield(FieldComments, SaveCommento);
//**************************************** aggiunta relativa ai commenti ******************************
  end;
end;

procedure AddMoviesTitles(Page: TStringList);
var
  LineNr: Integer;
  Line: string;
  MovieTitle, MovieAddress, Editor, year, MovieAuthor, Newmovietitle: string;
  BeginChar: string;
  BeginPos, EndPos: Integer;
begin
    TheMovieAddress := '*';
  LineNr := 0;
  LineNr := FindLine('<table width="100%" border="0" cellpadding="5" cellspacing="2" align="center"', page, 0);
  LineNr := FindLine('<td rowspan="3" width="5%" align="center" valign="top" >', page, LineNr);
while LineNr <> -1 do
  begin
    Line := Page.GetString(LineNr);   // riga dell'URL
    BeginChar := '<a  href="';
    MovieAddress := Textbetween(Line, BeginChar, '"');                   // link del libro
    EndPos := pos(BeginChar, Line) + length(MovieAddress) + 1;
    HTMLRemoveTags(MovieAddress);
    HTMLDecode(MovieAddress);
    MovieAddress := FullTrim(MovieAddress);
    TheMovieAddress := MovieAddress;
    Line := TextAfter(Line, Beginchar);

    BeginChar := 'title="';
    MovieTitle := Textbetween(Line, BeginChar, '"');   // titolo del libro
    HTMLRemoveTags(MovieTitle);
    HTMLDecode(MovieTitle);
    MovieTitle := FullTrim(MovieTitle);

    LineNr := LineNr + 1;
    Line := Page.GetString(LineNr);    // riga del titolo, autore, editore

    BeginChar := 'title="';
    MovieAuthor := Textbetween(Line, BeginChar, '"');             // salta campo titolo libro
    EndPos := pos(BeginChar, Line) + length(BeginChar) + length(MovieAuthor) + 1;
    delete(line, 1, EndPos);

    BeginChar := 'title="';
    MovieAuthor := Textbetween(Line, BeginChar, '"');             // Editore
    EndPos := pos(BeginChar, Line) + length(BeginChar) + length(MovieAuthor) + 1;
    delete(line, 1, EndPos);
    MovieTitle := MovieTitle + ' (' + MovieAuthor + ' - ';

    BeginChar := 'title="';
    MovieAuthor := Textbetween(Line, BeginChar, '"');             // Autore
    EndPos := pos(BeginChar, Line) + length(BeginChar) + length(MovieAuthor) + 1;
    MovieTitle := MovieTitle + MovieAuthor + ')';

    PickTreeAdd(Movietitle, MovieAddress);
    TheMovieAddress := '*';
    LineNr := LineNr + 1;
    LineNr := FindLine('<td rowspan="3" width="5%" align="center" valign="top" >', page, LineNr);
  end;
  if TheMovieAddress='*' then TheMovieAddress := '';
end;

// -----------------------------
// Questo è il main dello script
// -----------------------------
begin
  if CheckVersion(3,5,0) then
   begin
    MovieName := StringReplace(GetField(fieldTranslatedTitle), ' ', '+');
    if MovieName = '' then
      MovieName := StringReplace(GetField(fieldOriginalTitle), ' ', '+');
    if Input('LibreriaUniversitaria Import', 'Digita il titolo del libro:', MovieName) then
    begin
//      AnalyzePage('http://www.libreriauniversitaria.it/c_search.php?noinput=1&shelf=BIT&title_query='+UrlEncode(MovieName)+'&author_query=&publisher_query=&series_query=&subject_query=&isbn_query=&dewey_query=AAA&search=Cerca');
    InitSearch := 'http://www.libreriauniversitaria.it/c_advanced_search.php?query=1&query_shelf=BIT&query_title=' + MovieName;
    EndSearch  := '&query_author=&query_publisher=&query_series=&query_abstract=&query_code=&query_category=AAA&query_availability=ALL&query_date_range=bef&query_date=2009&query_order_by=DEF&search=Cerca';
    UrlSearch  := InitSearch + EndSearch;
//  SetField(fieldURL, UrlSearch);            //URL della ricerca
    AnalyzePage(UrlSearch);
    end;
   end
  else
    ShowMessage('Questo script richiede una versione più nuova di Ant Movie Catalog (almeno la versione 3.5.0)');
end.
Bye :)

Posted: 2009-09-24 11:27:11
by lsscpp
Hi fulvio! Tested the script.. it doesn't work :(
I tried a debug, but didn't get where the problem is.
So far the script retrieves only the cover


Ciao Fulvio. ho testato lo script... no funziona :(
provato debug, non sa dove è il problema
per ora llo script recupera solo le cover

bye

Posted: 2009-09-30 10:23:44
by lsscpp
hi, i've looked into the script but really didn't get where the problem is.
it gives a 404 error when you search a book which is unavalaible (the book not the page) and has no cover.
any news?

Posted: 2009-09-30 13:39:18
by fulvio53s03
Mi spiace per il ritardo, non avevo visto la segnalazione dell'errore.
Verifico.

Sorry for my being late, I didn't see your error message.
I'm going to give a sight.
;)

Code: Select all

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=
Title=Libreria Universitaria.IT.ifs
Description=
Site=
Language=IT
Version=
Requires=3.5.1
Comments=
License=
GetInfo=1

[Options]

***************************************************)

(***************************************************

Ant Movie Catalog importation script
www.antp.be/software/moviecatalog/

[Infos]
Authors=
Title=Libreria Universitaria
Description=
Site=
Language=?
Version=
Requires=3.5.0
Comments=
License=
GetInfo=0

[Options]

***************************************************)

program libri;
uses
  StringUtils1;

var
  MovieName: string;
  TheMovieAddress: string;
  UrlSearch, InitSearch, EndSearch: string;
  comm: String;
const
  crlf = #13#10;                        // carriage return/line feed
  virgolette = #187;
  
procedure AnalyzePage(Address: string);
var
  Page: TStringList;
  LineNr: integer;
  BeginPos: integer;
begin
  Page := TStringList.Create;
//ex  Page.Text := GetPage(Address);
  Page.Text := GetPage(Address);
  SetField(fieldURL, Address);
  LineNr := FindLine('class="small_font">Risultati per la tua ricerca', Page, 0);
  if LineNr = -1 then
  begin
    SetField(fieldURL, Address);
    AnalyzeMoviePage(Page);
  end
  else
  begin
    PickTreeClear;
    AddMoviesTitles(Page);
    if TheMovieAddress='' then
    begin
      if PickTreeExec(Address) then AnalyzePage(Address);
    end
    else
    begin
      SetField(fieldURL, MovieAddress);
      Page.Text := GetPage(Address); //Page.Text := GetPage(TheMovieAddress);
      AnalyzeMoviePage(Page);
    end;
  end;
  Page.Free;
end;

procedure AnalyzeMoviePage(Page: TStringList);    //estrae campi dalla pagina del libro scelto
var
  SaveLine, Line, Value, PreviousLine, NomeHtml, sTemp: string;
  LineNr, LengthLine: Integer;
  BeginPos, EndPos, Field: Integer;
  BeginDiv, EndDiv: Integer;
  LengthDiv: Integer;
  InCatalogo: string;
  BeginChar, EndChar: string;
  SaveCommento, Commento: string;
  BeginLineNr, endLineNr: Integer;

begin
  InCatalogo := 'si';
  LineNr := FindLine('>Fuori catalogo - Non acquistabile</span>', Page, 0);         // vedi se in catalog
  if LineNr <> -1 then
     InCatalogo := 'no';
  if InCatalogo = 'si' then
     LineNr := FindLine('<h3 class="product_section_title">Descrizione</h3>', Page, 0);
  if InCatalogo = 'no' then
     LineNr := FindLine('class="product_section_title">Dettagli del libro</h3>', Page, 0);
  if (LineNr <> -1) then
   begin
//     LineNr := LineNr + 1;
     Line := Page.GetString(LineNr);
     saveLine := Line;
     Line := TextBetween(Line, '<div class="product_text" >', '</div>');    //trama     param. 2
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     setfield(FieldDescription, Line);

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Traduttore:</span>', '</span>'); // estrae Traduttore   param. 3
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        Line := 'Traduttore: ' + Line;
        setfield(FieldActors, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Editore:</span>', '</span>'); // estrae Editore   param. 3
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        Line := 'Editore: ' + Line;
        setfield(FieldProducer, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Data di Pubblicazione:</span>', '</span>'); // estrae Pubblicazione
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        setfield(FieldYear, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Collana:</span>', '</span>'); // estrae Collana   param. 3
     Line := TextBetween(Line, 'title="', '"');                                           // estrae Collana   param. 3
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        Line := 'Collana: ' + Line;
        setfield(Fieldcategory, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">ISBN:</span>', '</span>'); // estrae ISBN
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        Line := 'ISBN: ' + Line;
        setfield(FieldVideoFormat, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">ISBN-13:</span>', '</span>'); // estraeISBN13
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     if Length(Line) > 0 then
        begin
        Line := 'ISBN13: ' + Line;
        setfield(FieldAudioFormat, Line);
        end

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Pagine:</span>', '</span>'); // estrae n.pagine
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     setfield(FieldLength, Line);

     Line := SaveLine;
     Line := TextBetween(Line, '<span class="product_label">Titolo:</span>', '</span>'); // estrae Titolo  param. 4
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     setfield(FieldTranslatedTitle, Line);
   end;
   
  if (LineNr <> -1) and (Incatalogo = 'si') then
   begin
     LineNr := FindLine('<h2 class="product_text"', Page, 0);
     Line := Page.GetString(LineNr);
     Line := TextBetween(Line, 'title="', '"'); // estrae Autore
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     setfield(FieldDirector, Line);

     LineNr := FindLine('<br /><table border=0 cellspacing="12">', Page, 0);    // inizio estrazione commenti
     Line := Page.GetString(LineNr);
     Line := TextBetween(Line, 'title="', '"'); // estrae Autore
     HTMLRemoveTags(Line);
     HTMLDecode(Line);
     Line := Fulltrim(Line);
     setfield(FieldDirector, Line);
     
//********************************* inizio estrazione commenti ******************************
     BeginLineNr := FindLine('<br /><table border=0 cellspacing="12">', Page, 0);              // inizio estrazione commenti
     EndLineNr   := FindLine('</table>', Page, BeginLinenr);    // fine estrazione commenti
     Line := '';
     While BeginLineNr <= EndLineNr do
        begin
        Line := Line + Page.GetString(BeginLineNr);    // inizio estrazione commenti
        beginLineNr := BeginLineNr + 1;
        end;
     LengthLine := length(Line);
     SaveCommento := '';
     BeginDiv := Pos('<div class', Line);
     Delete(Line, 1, BeginDiv - 1);    // ora Line comincia con <div class
     SaveLine := Line;
     BeginChar := 'border="0" > <b>';                     // 1
     EndChar   := '<br />';
     Commento := TextBetween(Line, BeginChar, EndChar); // estrae commento succinto
//     setfield(FieldComments, Line);
     While Commento <> '' do
        begin
        EndDiv := Pos('</div>', Line) + Length('</div>');    // lunghezza della divisione <div> </div>
        
        EndPos := Pos(EndChar, Line);
        delete(Line, 1, Endpos - 1);
        LengthLine := length(Line);
        HTMLRemoveTags(Commento);
        HTMLDecode(Commento);
//        Commento := Fulltrim(Commento);
        SaveCommento := SaveCommento + Commento + ' ';

        BeginChar := '<br />';
        EndChar   := '<b>';
        Commento := TextBetween(Line, BeginChar, EndChar); // 2
        EndPos := Pos(EndChar, Line);
        delete(Line, 1, Endpos - 1);
        LengthLine := length(Line);
        HTMLRemoveTags(Commento);
        HTMLDecode(Commento);
//        Commento := Fulltrim(Commento);      // appena ripristinato
        SaveCommento := SaveCommento + Commento;

        BeginChar := '<b>';
        EndChar   := '</b>';
        Commento := TextBetween(Line, BeginChar, EndChar); // 3
        EndPos := Pos(EndChar, Line);
        delete(Line, 1, Endpos - 1);
        LengthLine := length(Line);
        HTMLRemoveTags(Commento);
        HTMLDecode(Commento);
        Commento := Fulltrim(Commento);
        SaveCommento := SaveCommento + Commento + ' - ';

        BeginChar := '>leggi tutte le sue recensioni</a><br /><br /><font color="#67b00e">';                   // estrae commento esteso
        EndChar   := '<font color=';
        Commento := TextBetween(Line, BeginChar, EndChar); // estrae commento succinto
        EndPos := Pos(EndChar, Line);
        delete(Line, 1, Endpos - 1);
        LengthLine := length(Line);
        HTMLRemoveTags(Commento);
        HTMLDecode(Commento);
        Commento := Fulltrim(Commento);
        SaveCommento := SaveCommento + Commento + ' ' + virgolette + crlf;     // qui aggiunge virgolette
        
        EndChar   := 'rel="nofollow"';
        EndPos := Pos(EndChar, Line) + length(EndChar);
        delete(Line, 1, Endpos -1);
        EndChar   := 'rel="nofollow"';
        EndPos := Pos(EndChar, Line) + length(EndChar);
        delete(Line, 1, Endpos - 1);

        BeginDiv := Pos('<div class', Line);
        Delete(Line, 1, BeginDiv - 1);    // ora Line comincia con <div class

        BeginChar := 'border="0" > <b>';
        EndChar   := '<br />';
        Commento := TextBetween(Line, BeginChar, EndChar); // estrae commento succinto
     end;
    end;
    setfield(FieldComments, SaveCommento);
//**************************************** fine estrazione commenti ******************************
// Picture import            <table width="100%" cellpadding="8" border="0">     // per non trovato??????
    LineNr := FindLine('<table width="100%" cellpadding="8" border="0">', Page, 0);
    Line := Page.GetString(LineNr);
    Line := TextBetween(Line, 'src="', '" height="240"');   // Extract the picture URL from "Page"
//    HTMLRemoveTags(Line);
//    HTMLDecode(Line);
//    setfield(FieldURL, Line);
  if InCatalogo = 'si' then
     begin
     if Line <> '' then   // If "Value" now contains picture URL then..
        GetPicture(Line);   // .. download and save picture
     end;
end;

procedure AddMoviesTitles(Page: TStringList);
var
  LineNr: Integer;
  Line: string;
  MovieTitle, MovieAddress, Editor, year, MovieAuthor, Newmovietitle: string;
  BeginChar: string;
  BeginPos, EndPos: Integer;
  begin
    TheMovieAddress := '*';
  LineNr := 0;
  LineNr := FindLine('<table width="100%" border="0" cellpadding="5" cellspacing="2" align="center"', page, 0);
  LineNr := FindLine('<td rowspan="3" width="5%" align="center" valign="top" >', page, LineNr);
while LineNr <> -1 do
  begin
    Line := Page.GetString(LineNr);   // riga dell'URL
    BeginChar := '<a  href="';
    MovieAddress := Textbetween(Line, BeginChar, '"');                   // link del libro
    EndPos := pos(BeginChar, Line) + length(MovieAddress) + 1;
    HTMLRemoveTags(MovieAddress);
    HTMLDecode(MovieAddress);
    MovieAddress := FullTrim(MovieAddress);
    TheMovieAddress := MovieAddress;
    Line := TextAfter(Line, Beginchar);

    BeginChar := 'title="';
    MovieTitle := Textbetween(Line, BeginChar, '"');   // titolo del libro
    HTMLRemoveTags(MovieTitle);
    HTMLDecode(MovieTitle);
    MovieTitle := FullTrim(MovieTitle);

    LineNr := LineNr + 1;
    Line := Page.GetString(LineNr);    // riga del titolo, autore, editore

    BeginChar := 'title="';
    MovieAuthor := Textbetween(Line, BeginChar, '"');             // salta campo titolo libro
    EndPos := pos(BeginChar, Line) + length(BeginChar) + length(MovieAuthor) + 1;
    delete(line, 1, EndPos - 1);

    BeginChar := 'title="';
    MovieAuthor := Textbetween(Line, BeginChar, '"');             // Editore
    EndPos := pos(BeginChar, Line) + length(BeginChar) + length(MovieAuthor) + 1;
    delete(line, 1, EndPos - 1);
    MovieTitle := MovieTitle + ' (' + MovieAuthor + ' - ';

    BeginChar := 'title="';
    MovieAuthor := Textbetween(Line, BeginChar, '"');             // Autore
    EndPos := pos(BeginChar, Line) + length(BeginChar) + length(MovieAuthor) + 1;
    MovieTitle := MovieTitle + MovieAuthor + ')';

    PickTreeAdd(Movietitle, MovieAddress);
    TheMovieAddress := '*';
    LineNr := LineNr + 1;
    LineNr := FindLine('<td rowspan="3" width="5%" align="center" valign="top" >', page, LineNr);
  end;
  if TheMovieAddress='*' then TheMovieAddress := '';
end;

// -----------------------------
// Questo è il main dello script
// -----------------------------
begin
  if CheckVersion(3,5,0) then
   begin
    MovieName := StringReplace(GetField(fieldTranslatedTitle), ' ', '+');
    if MovieName = '' then
      MovieName := StringReplace(GetField(fieldOriginalTitle), ' ', '+');
    if Input('LibreriaUniversitaria Import', 'Digita il titolo del libro:', MovieName) then
    begin
//      AnalyzePage('http://www.libreriauniversitaria.it/c_search.php?noinput=1&shelf=BIT&title_query='+UrlEncode(MovieName)+'&author_query=&publisher_query=&series_query=&subject_query=&isbn_query=&dewey_query=AAA&search=Cerca');
    InitSearch := 'http://www.libreriauniversitaria.it/c_advanced_search.php?query=1&query_shelf=BIT&query_title=' + MovieName;
    EndSearch  := '&query_author=&query_publisher=&query_series=&query_abstract=&query_code=&query_category=AAA&query_availability=ALL&query_date_range=bef&query_date=2009&query_order_by=DEF&search=Cerca';
    UrlSearch  := InitSearch + EndSearch;
//  SetField(fieldURL, UrlSearch);            //URL della ricerca
    AnalyzePage(UrlSearch);
    end;
   end
  else
    ShowMessage('Questo script richiede una versione più nuova di Ant Movie Catalog (almeno la versione 3.5.0)');
end.
Questo funziona..... provato!

This is OK, I'm sure (on my computer).
:grinking: