#!D:/Python/python.exe import os import sys import string import win32pipe def main(): #if main returns 0 the user will get an error message theQuery=os.environ['QUERY_STRING'] #Build an exec string to pass to the OS execString="c:\opt\www\cgi-bin\htsearch.exe " execString=execString + '"' execString=execString + theQuery execString=execString + '" ' #Do the search; put the result page into a temporary file resultsFile=win32pipe.popen(execString, 'r') if (resultsFile): resultsOut=resultsFile.read() resultsTestLine=string.split(resultsOut, "\n") resultsFile.close() if (string.find(resultsTestLine[2], "
Search Word | Suggested Spelling(s) Click on a suggestion to search for that word |
" fragment=string.split(Line, ":") origWordList=string.split(fragment[0]) origWord=origWordList[1] replaceString=replaceString + origWord + " | " suggestList=string.split(fragment[1], ", ") newQuery=string.lower(theQuery) for suggestWord in suggestList: suggestWord1=string.strip(suggestWord) newQuery1=string.replace(newQuery, origWord, suggestWord1) replaceString=replaceString + "" + suggestWord1 + " " replaceString=replaceString +" |
There was some sort of error.
\n" print "\n\n"