program NewbieScript; { Basic script to prompt user for book search keyword in Amazon. The search results are save in an Excel file c:\amazon.xls } const ExcelFile = 'c:\amazon.xls'; var sData : string; sSearchStr : string; { Process events here } procedure OnDocumentComplete(URL : string); begin if IsPartOf('http://www.amazon.com/exec/obidos/ats-query-page', URL) then begin // assign search string to title field Fill('field-title', sSearchStr); // search button does not have a name, no way to reference it, just press enter SendKeyPress('Enter'); end; if IsPartOf('http://www.amazon.com/exec/obidos/search-handle-form/ref', URL) or IsPartOf('http://www.amazon.com/exec/obidos/search-handle-url/ref', URL) then begin // get all results at html table 18,1,2; use ClickCapture to get position sData := GetTableCell(23,1,2); // append extracted results to file TextAppendToFile(ExcelFile, sData); NewbieScriptEnd; end; end; { This is the main program body. } begin DeleteFile(ExcelFile); // ask what title to search for sSearchStr := Readln('Enter search string:'); Navigate('http://www.amazon.com/exec/obidos/ats-query-page/ref=b_tn_bh_bo/002-3070511-5218419'); end.