program NewbieScript; { Basic script to search Abebooks for a list of books defined in c:\abelisttitle.txt that contains the title and author and output the search results to an Excel file } const ExcelFile = 'c:\abe.xls'; MyTitleList = 'c:\abelistTitle.txt'; var sData : string; sSearchTitle : string; sSearchAuthor : string; { Process events here } procedure OnDocumentComplete(URL : string); begin if IsPartOf('http://dogbert.abebooks.com/servlet/SearchEntry', URL) then begin // assign search string to title and author field Fill('tn', sSearchTitle); Fill('an', sSearchAuthor); // search button has value of 'Start Search' SendKeyPress('Enter'); end; if IsPartOf('http://dogbert.abebooks.com/servlet/SearchResults', URL) then begin // get all results at html table 2,2,0 sData := GetTableCell(2,2,0); // append extracted results to excel file TextAppendToFile(ExcelFile, sData); if not(EndOfFile) then begin Readfl(sSearchTitle); Readfl(sSearchAuthor); GotoURL('http://dogbert.abebooks.com/servlet/SearchEntry'); end else begin CloseFile; NewbieScriptEnd; end; end; end; { This is the main program body. } begin Reset(MyTitleList); if not(EndOfFile) then begin Readfl(sSearchTitle); Readfl(sSearchAuthor); Navigate('http://dogbert.abebooks.com/servlet/SearchEntry'); end; end.