首页 > 代码库 > 用ASP做一个TOP COOL的站内搜索
用ASP做一个TOP COOL的站内搜索
该搜索引擎由一个HTM文件一个ASP文件组成,主要是运用FILESYSTEMOBJECT组件来达到目的,功能强大,修改界面以后可以直接拿来使用,当然加上一点自己的东西就更加好了。
searchpage.htm
该HTM文件用来传入条件
<HTML>
<HEAD>
<TITLE>ASP搜索引擎范例</TITLE>
</HEAD>
<BODY>
<CENTER>
<FORM METHOD=POST ACTION="search.asp">
<TABLE BGCOLOR="#CC6633" BORDER="0">
<TR>
<TD ROWSPAN="3" BGCOLOR="#CC6633" width="21" nowrap> </TD>
<TD width="363" nowrap> <FONT COLOR="#FFFFFF">
<INPUT TYPE="text" NAME="SearchText" SIZE="22">
<INPUT TYPE="checkbox" NAME="Case">
高度敏感</FONT> </TD>
<TD ROWSPAN="3" width="10">
<INPUT TYPE="submit" VALUE=http://www.mamicode.com/"确定">
<P>
<INPUT TYPE="reset" VALUE=http://www.mamicode.com/"清除">
</TD>
<TD ROWSPAN="3" BGCOLOR="#CC6633" width="28"> </TD>
</TR>
<TR>
<TD width="363" nowrap> <FONT COLOR="#FFFFFF"> 返回结果
<SELECT name="rLength" >
<option value=http://www.mamicode.com/"200" selected>长信息
<option value=http://www.mamicode.com/"100">短信息
<option value=http://www.mamicode.com/"0">只返回连接
</SELECT>
<SELECT NAME="rResults">
<OPTION VALUE=http://www.mamicode.com/"10" SELECTED>10
<OPTION VALUE=http://www.mamicode.com/"25">25
<OPTION VALUE=http://www.mamicode.com/"50">50
</SELECT>
</FONT>
</TD>
</TR>
<TR>
<TD width="363" nowrap> <FONT COLOR="#FFFFFF"> 必须包括:
<INPUT TYPE="checkbox" NAME="iImage">
图片
<INPUT TYPE="checkbox" NAME="iZips">
Zip格式
<INPUT TYPE="checkbox" NAME="iJavaS"> JavaScript
</FONT>
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>
<DL>
<DD> </DD>
</DL>
</BODY>
</HTML>
------------------------------------------------------------------------
显示结果的ASP程序
search.asp
<HTML>
<HEAD>
<TITLE>‘<%=Request("SearchText")%>‘的搜索结果</TITLE>
</HEAD>
<BODY>
<B>‘<%=Request("SearchText")%>‘的搜索结果</B><BR>
<%
Const fsoForReading = 1
Dim objFile, objFolder, objSubFolder, objTextStream
Dim bolCase, bolFileFound, bolTagFound
Dim strCount, strDeTag, strExt, strFile, strContent, strRoot, strTag, strText, strTitle, strTitleL
Dim reqImage, reqJavaS, reqLength, reqNumber, reqZip
strFile = ".asp .htm .html .js .txt .css"
strRoot = "/"
strText = Request("SearchText")
strTag = Chr(37) & Chr(62)
bolFileFound = False
bolTagFound = False
If Request("Case") = "on" Then bolCase = 0 Else bolCase = 1
If Request("iImage") = "on" Then reqImage = "<IMG" Else reqImage = ""
If Request("iZips") = "on" Then reqZips = ".zip" Else reqImage = ""
If Request("iJavaS") = "on" Then reqJavaS = "JavaScript" Else reqImage = ""
If Request("rResults") = "10" Then reqNumber = 10
If Request("rResults") = "25" Then reqNumber = 25
If Request("rResults") = "50" Then reqNumber = 50
reqLength = Request("rLength")
%>