program Half_Com; { Basic script to search Half.Com for a list of books defined in c:\TitleAuthor.txt and output the search results in c:\HalfCom.xls TitleAuthor.txt format is as follows: Title1 Author1 Title2 Author2 ... } const ExcelFile = 'c:\HalfCom.xls'; MyList = 'c:\TitleAuthor.txt'; var sSearchTitle : string; sSearchAuthor : string; sData : string; nCount : integer; { Process events here } procedure OnDocumentComplete(URL : string); begin if IsPartOf('http://www.half.ebay.com/books-adv-search', URL) then begin // assign search string to title and author field Fill('bt', sSearchTitle); Fill('au', sSearchAuthor); // search button has value of 'Start Search' SendKeyPress('Enter'); end; if IsPartOf('http://product.half.ebay.com/', URL) then begin // get all results at html table 14,0,2 sData := GetTableCell(14,0,2); // append extracted results to excel file TextAppendToFile(ExcelFile, sData); // read next search keyword from file if not(EndOfFile) then begin Readfl(sSearchTitle); Readfl(sSearchAuthor); GotoURL('http://www.half.ebay.com/books-adv-search'); end else CloseFile; end else if IsPartOf('http://search.half.ebay.com/', URL) then begin // get all results at html table 14,0,2 sData := GetTableCell(14,0,2); // if search empty don't save contents of cell to Excel if not IsPartOf('Try again...' , sData) then TextAppendToFile(ExcelFile, sData); // get next search parameters if not(EndOfFile) then begin Readfl(sSearchTitle); Readfl(sSearchAuthor); GotoURL('http://www.half.ebay.com/books-adv-search'); end else CloseFile; end; end; { This is the main program body. } begin nCount := 1; Reset(MyList); if not(EndOfFile) then begin Readfl(sSearchTitle); Readfl(sSearchAuthor); Navigate('http://www.half.ebay.com/books-adv-search'); end; end.