您现在的位置: 军旅同心-旅游自驾-军旅文学 >> 读书赏析 >> 学习园地 >> 电脑网络 >> 技术文章 >> 正文
用ASP做一个TOP COOL的站内搜索
作者:采集员 文章来源:来源于网络 点击数: 更新时间:2005-9-10 14:19:43
该搜索引擎由一个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>&nbsp; </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="确定">
                                <P>
                            
            <INPUT TYPE="reset" VALUE="清除">
                        </TD>
                        
        <TD ROWSPAN="3" BGCOLOR="#CC6633" width="28">&nbsp; </TD>
                    </TR>
                    <TR>
                        
        <TD width="363" nowrap> <FONT COLOR="#FFFFFF"> 返回结果
          <SELECT name="rLength" >
            <option value="200" selected>长信息 </option>
            <option value="100">短信息</option>
            <option value="0">只返回连接</option>
          </SELECT>
                                <SELECT NAME="rResults">
                                    <OPTION VALUE="10" SELECTED>10
                                    <OPTION VALUE="25">25
                                    <OPTION VALUE="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>&nbsp; </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")

Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder(Server.MapPath(strRoot))

schSubFol(objFolder)

Sub schSubFol(objFolder)
    For Each objFile in objFolder.Files
        If strCount + 1 > reqNumber or strText = "" Then Exit Sub
        If Response.IsClientConnected Then
            Set objTextStre

[1] [2] 下一页


更多
免责声明:作品版权归所属媒体与作者所有!!本站刊载此文不代表同意其说法或描述,仅为提供更多信息。如果您认为我们侵犯了您的版权,请告知!本站立即删除。有异议请联系我们。
文章录入:烟灰缸    责任编辑:烟灰缸 
网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
| 设为首页 | 加入收藏 | 联系站长 | 友情链接 | 网站地图 | 版权申明 | 网站公告 | 管理登录 |