// ce scripte a pour but de vous montrer comment aspirer les résultats de l'annuaire Indexa

AUTORUN;
 // ici la définitions des variables
var i,j:integer;
var s,description : string;
var email : string;
var Nom : string;
var adresse:string;
var SiteWeb : string;
var url,protocol,host,path,document:string;
var ajoutes:integer;

createTable('adresse','description','email','Nom','SiteWeb');

showDatabase;
SetUniqueColumn('nom');


//navigate('http://www.indexa.fr',1);
//ShowMessage('Naviguez jusqu''à obtention des résultats');
repeat;
ajoutes:=recordCount;

for i:=22 downto 0 do begin;
    s:='TD(1)/TR(2)/TBODY(0)/TABLE(0)/TD(0)/TR(0)/TBODY(0)/TABLE('+inttostr(i)+')/TD(0)/TR(0)/TBODY(0)/TABLE(2)/TD(0)/TR(0)/TBODY(0)/TABLE(0)/TD(3)/TR(0)/TBODY(0)/TABLE(1)/BODY(0)/HTML(0)/';
    nom:=gettext(s,1);
    s:=getHTML(s,1);
    SiteWeb:=extractUrlsfromString(s);
    if pos('overture',siteweb)>0 then siteweb:='';
    s:='TD(0)/TR(2)/TBODY(0)/TABLE(0)/TD(0)/TR(0)/TBODY(0)/TABLE('+inttostr(i)+')/TD(0)/TR(0)/TBODY(0)/TABLE(2)/TD(0)/TR(0)/TBODY(0)/TABLE(0)/TD(3)/TR(0)/TBODY(0)/TABLE(1)/BODY(0)/HTML(0)/';
    adresse:=gettext(s,1);
    s:='TD(0)/TR(1)/TBODY(0)/TABLE(0)/TD(0)/TR(0)/TBODY(0)/TABLE('+inttostr(i)+')/TD(0)/TR(0)/TBODY(0)/TABLE(2)/TD(0)/TR(0)/TBODY(0)/TABLE(0)/TD(3)/TR(0)/TBODY(0)/TABLE(1)/BODY(0)/HTML(0)/';
    description:=gettext(s,1);
    if nom<>'' then begin;
           parseURL(SiteWeb,protocol,host,path,document);

           if host<>'' then email:='contact@'+host;
           ReplaceS(email,'www.','',True);
           InsertData(adresse,description,email,Nom,SiteWeb);

    end;
end;
clickForm('A(0)/TD(0)/TR(0)/TBODY(0)/TABLE(1)/TD(0)/TR(0)/TBODY(0)/TABLE(0)/TD(3)/TR(0)/TBODY(0)/TABLE(1)/BODY(0)/HTML(0)/',1);

ajoutes:=recordcount-ajoutes;
until (ajoutes=0);