您的位置:首页精文荟萃软件资讯 → 用ASP做一个TOP COOL的站内搜索

用ASP做一个TOP COOL的站内搜索

时间:2004/10/7 19:08:00来源:本站整理作者:蓝点我要评论(2)


            
             
              
             
            

               
               

            



            该搜索引擎由一个HTM文件一个ASP文件组成,主要是运用FILESYSTEMOBJECT组件来达到目的,功能强大,修改界面以后可以直接拿来使用,当然加上一点自己的东西就更加好了。

searchpage.htm
该HTM文件用来传入条件



ASP搜索引擎范例



























高度敏感





返回结果



必须包括:

图片

Zip格式
JavaScript











------------------------------------------------------------------------
显示结果的ASP程序
search.asp



'<%=Request("SearchText")%>'的搜索结果


'<%=Request("SearchText")%>'的搜索结果

<%
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 = "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 objTextStream = objFSO.OpenTextFile(objFile.Path,fsoForReading)

strContent = objTextStream.ReadAll

If InStr(1, strContent, strTag, bolCase) Then
Else
If Mid(objFile.Name, Len(objFile.Name) - 1, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 1, 2)
If Mid(objFile.Name, Len(objFile.Name) - 2, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 2, 3)
If Mid(objFile.Name, Len(objFile.Name) - 3, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 3, 4)
If Mid(objFile.Name, Len(objFile.Name) - 4, 1) = "." Then strExt = Mid(objFile.Name, Len(objFile.Name) - 4, 5)
If InStr(1, strContent, strText, bolCase) And _
InStr(1, strContent, reqImage, 1) And _
InStr(1, strContent, reqZips, 1) And _
InStr(1, strContent, reqJavaS, 1) And _
Instr(1, strFile, strExt, 1) Then
If InStr(1, strContent, "", 1) Then strTitle = Mid(strContent, InStr(1, strContent, "<TITLE>", 1) + 7, InStr(1, strContent, "", 1)) Else strTitle = "未命名"

strCount = strCount + 1
Response.Write "
"& strCount &" - " & strTitle & "

"
strTitleL = InStr(1, strContent, "", 1) - InStr(1, strContent, "", 1) + 7 <BR><BR>strDeTag = "" <BR>bolTagFound = False <BR><BR>Do While InStr(strContent, "<") <BR>bolTagFound = True <BR>strDeTag = strDeTag & " " & Left(strContent, InStr(strContent, "<") - 1) <BR>strContent = MID(strContent, InStr(strContent, ">") + 1) <BR>Loop <BR><BR>strDeTag = strDeTag & strContent <BR>If Not bolTagFound Then strDeTag = strContent <BR><BR>If reqLength = "0" Then Response.Write objFile.Path & "</DD></DL>" Else Response.Write Mid(strDeTag, strTitleL, reqLength) & "...<BR><b><FONT SIZE='2'>URL: " & objFile.Path & " - 上次修改时间: " & objFile.DateLastModified & " - " & FormatNumber(objFile.Size / 1024) & "Kbytes</FONT></b></DD></DL>" <BR>bolFileFound = True <BR>End If <BR>objTextStream.Close <BR>End If <BR>End If <BR>Next <BR>End Sub <BR><BR>For Each objSubFolder in objFolder.SubFolders <BR>schSubFol(objSubFolder) <BR>Next <BR><BR>If Not bolFileFound then Response.Write "没有匹配结果" <BR>If bolFileFound then Response.Write "<B>搜索结束</B>" <BR><BR>Set objTextStream = Nothing <BR>Set objFolder = Nothing <BR>Set objFSO = Nothing <BR>%> <BR></BODY></HTML> <BR><BR> </dd> </dl> <div id="xgsp"><p class="tit"><em>相关视频</em></p> <div class="sp-wrap"> <ul class="clearfix"> <li><a href="/video/35627.html" target="_blank"><img src="https://thumb.jfcdns.com/n131f33y14414/7ef6220197161773.jpeg"><span>windows10自带扫雷游戏在哪</span></a></li><li><a href="/video/35608.html" target="_blank"><img src="https://thumb12.jfcdns.com/n331r1933t6b14n1e13/7ef621f2e386e59b.jpeg"><span>windows11专业版和家庭版的区别</span></a></li><li><a href="/video/35609.html" target="_blank"><img src="https://thumb.jfcdns.com/n3319v533e4014eln13/7ef621f2ef964d53.jpeg"><span>windows11家庭版和专业版有什么区别</span></a></li><li><a href="/video/35470.html" target="_blank"><img src="https://thumb2.jfcdns.com/n3315vb331dh13emv38/7ef621b17fd6b5e5.jpeg"><span>windows11我的电脑在哪里打开</span></a></li><li><a href="/video/35469.html" target="_blank"><img src="https://thumb12.jfcdns.com/n3313eu3330g1365f38/7ef621b16c26f688.jpeg"><span>windows11我的电脑在哪</span></a></li><li><a href="/video/35466.html" target="_blank"><img src="https://thumb10.jfcdns.com/n331xf6331dy13drs38/7ef621b10e146fcf.jpeg"><span>win11系统怎么退出微软账号</span></a></li><li><a href="/video/35091.html" target="_blank"><img src="https://thumb10.jfcdns.com/n231sp33cd134j22/7ef62061e5f02b61.jpeg"><span>win10ie打开变成edge</span></a></li><li><a href="/video/34798.html" target="_blank"><img src="https://thumb10.jfcdns.com/n331zf433u2x1212t36/7ef61efa5c1e0e6e.jpeg"><span>win11怎么设置默认浏览器</span></a></li><li><a href="/video/34683.html" target="_blank"><img src="https://thumb11.jfcdns.com/n2317533wl12ji32/7ef61ea73b416974.jpeg"><span>win11 ie浏览器在哪里</span></a></li><li><a href="/video/34071.html" target="_blank"><img src="https://thumb10.jfcdns.com/n131032w23h42/7ef61ce5b1bddfd3.jpeg"><span>windows11怎么连接wifi</span></a></li><li><a href="/video/34070.html" target="_blank"><img src="https://thumb10.jfcdns.com/n131q32823t42/7ef61ce5a5e38c81.jpeg"><span>windows11有必要升级吗</span></a></li><li><a href="/video/34069.html" target="_blank"><img src="https://thumb10.jfcdns.com/n131632l23o42/7ef61ce59b2d938d.jpeg"><span>windows11怎么把我的电脑放在桌面上</span></a></li><li><a href="/video/33644.html" target="_blank"><img src="https://thumb1.jfcdns.com/n331j1l32yg223ums26/7ef61b9add7dbd37.jpeg"><span>win10怎么隐藏任务栏</span></a></li><li><a href="/video/33524.html" target="_blank"><img src="https://thumb2.jfcdns.com/n331g1e3240e23utf23/7ef61b5b9fbe02f8.jpeg"><span>win10任务栏颜色怎么改</span></a></li><li><a href="/video/33520.html" target="_blank"><img src="https://thumb11.jfcdns.com/n331n4m32waz23w6023/7ef61b5b5c19d8a4.jpeg"><span>win10已禁用输入法怎么解决</span></a></li> </ul> </div> </div> <p id="lread"> <b class="tit"><em>相关阅读</em></b> <span> <i><a href="/infoview/Article_181275.html">Windows错误代码大全 Windows错误代码查询</a></i><i><a href="/edu/180591.html">激活windows有什么用</a></i><i><a href="/edu/142370.html">Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录</a></i><i><a href="/infoview/Article_140347.html">Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新</a></i><i><a href="/infoview/Article_136060.html">windows 10 rs4快速预览版17017下载错误问题</a></i><i><a href="/infoview/Article_133896.html">Win10秋季创意者更新16291更新了什么 win10 16291更新内容</a></i><i><a href="/infoview/Article_131339.html">windows10秋季创意者更新时间 windows10秋季创意者更新内容</a></i><i><a href="/infoview/Article_118674.html">kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么</a></i> </span> </p> <dl id="commentBox"><dt class="tit"><i>文章评论</i></dt> <dd id="comment"> <div id="comment-list"> <div id="hotCmt"> </div> <dl> </dl> <p id="cmtNum-wrap"><a href="/comment_1831_1.html">查看所有<span id="cmtNum">2</span>条评论>></a></p> </div> <div id="comment-form"> <form action="/ajax.asp" method="post" id="cmtForm"> <fieldset> <legend>发表评论</legend> <input name="SoftID" type="hidden" id="softID" value="1831" /> <input name="CommentTpye" type="hidden" value="1" /> <input name="Action" type="hidden" value="2" /> <p id="userName-wrap"><input name="UserName" type="text" id="userName" class="input-bg grey9" maxLength="10" value="PC6网友" /></p> <p><textarea name="content" id="cmtMsg" class="input-bor">我来说两句...</textarea></p> <p><button type="submit" class="btn-submit button btnOrg fr" id="subCmt">提交评论</button></p> </fieldset> </form> </div> </dd><!-- #comment end --> </dl> </dt> <dd id="cside"> <div class="adr"></div> <p id="rpj"> <b class="tit"><em>热门文章</em></b> <span> <a href="/infoview/Article_118995.html"><img src="https://thumb10.jfcdns.com/up/2017-6/201761414444617963387.jpg" /><b>360快剪辑怎么使用 36</b></a><a href="/infoview/Article_68410.html"><img src="https://thumb10.jfcdns.com/up/2014-9/201491212754.jpg" /><b>金山词霸如何屏幕取词</b></a><a href="/infoview/Article_61812.html"><img src="https://thumb10.jfcdns.com/up/2013-4/20134425250931094380.jpg" /><b>百度收购PPS已敲定!3</b></a> </span> </p> <p id="wj"> <b class="tit"><em>最新文章</em></b> <span> <i><a href="/infoview/Article_196027.html"><img src="https://thumb1.jfcdns.com/n3319rg33iv414xe425/7ef622e99bb116ed.jpeg" /><b>微信3.6.0测试版更新了</b></a></i><i><a href="/infoview/Article_162802.html"><img src="https://thumb10.jfcdns.com/2018-07/bce5b3c5a7fae33f.jpeg" /><b>微信支付漏洞会造成哪</b></a></i> </span> <s> <a href="/infoview/Article_118995.html" target="_blank">360快剪辑怎么使用 360快剪辑软件使用方法介</a><a href="/infoview/Article_107082.html" target="_blank">酷骑单车是什么 酷骑单车有什么用</a><a href="/infoview/Article_90143.html" target="_blank">Apple pay与支付宝有什么区别 Apple pay与</a><a href="/infoview/Article_90129.html" target="_blank">贝贝特卖是正品吗 贝贝特卖网可靠吗</a> </s> </p> <p id="rwz"> <b class="tit"><em>人气排行</em></b> <span> <i><a href="/infoview/Article_65172.html" target="_blank">xp系统停止服务怎么办?xp系统升级win7系统方</a></i><i><a href="/infoview/Article_67898.html" target="_blank">电脑闹钟怎么设置 win7电脑闹钟怎么设置</a></i><i><a href="/infoview/Article_58963.html" target="_blank">office2013安装教程图解:手把手教你安装与</a></i><i><a href="/infoview/Article_368.html" target="_blank">qq影音闪退怎么办 QQ影音闪退解决方法</a></i><i><a href="/infoview/Article_50553.html" target="_blank">VeryCD镜像网站逐个数,电驴资料库全集</a></i><i><a href="/infoview/Article_56293.html" target="_blank">同步推是什么?同步推使用方法介绍</a></i><i><a href="/infoview/Article_54150.html" target="_blank">QQ2012什么时候出 最新版下载</a></i><i><a href="/infoview/Article_52591.html" target="_blank">EDiary——一款好用的电子日记本</a></i> </span> </p> </dd> </dl> <!--#include virtual="/include/footer/news_footer.html"--> <script type="text/javascript"> var _webInfo = {};_webInfo={Username:"网络虫虫",Type:"1",DateTime:"2004/10/7 19:08:00",Id:"1831"};</script> <script type="text/javascript" src="https://www.pc6.com/inc/jquery-1.4.2.min.js"></script> <script type="text/javascript" src="https://www.pc6.com/js/nwz.js"></script> <script type="text/javascript"> var pageClass=7; //读取文章人气 ViewCmsHits('hits',1831); $("#comment-list > dl > dd > p a:last-child").addClass("glBtn"); BindDing("#comment-list > dl > dd > p",1831,1);//顶 </script> <script type="application/ld+json"> { "@context": "https://zhanzhang.baidu.com/contexts/cambrian.jsonld", "@id": "http://www.pc6.com/infoview/Article_1831.html", "title": "用ASP做一个TOP COOL的站内搜索 _pc6资讯", "description": ",用ASP做一个TOP COOL的站内搜索", "pubDate": "2004-10-07T19:08:00", "upDate": "2004-10-07T19:08:00", "data":{ "WebPage":{ "pcUrl":"http://www.pc6.com/infoview/Article_1831.html", "wapUrl":"https://m.pc6.com/n/1831", "fromSrc":"pc6下载站" } } } </script> </body> </html>