PC6下载站

分类分类

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

关注+2004-10-07作者:蓝点


            
             
              
             
            

               
               

            



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

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



ASP<a href="http://www.pc6.com/pc/ssyqapp/" target="_blank">搜索引擎</a>范例



























高度敏感





返回结果



必须包括:

图片

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> <div class="share_area"><div class="share"><div id="nativeShare">分享:</div><div class="bdsharebuttonbox bdshare-button-style2-16" data-bd-bind="1501730758936"><a href="#" class="sina bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a><a href="#" class="qq bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a><a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a></div></div></div> </div> </section> <script>c()</script> <!-- 多版本下载APP --> <section class="historyver bottom_bor"> <div class="lookmore" id="lookmore" data-show='3'><span>展开全部</span><i></i></div> </section> <!-- 相关文章 --> <section class="xgwz bottom_bor p10" style="margin-top: 0"> <p class="dtit"><b>相关文章</b></p> <ul> <li><em></em><a href="/n/181275">Windows错误代码大全 Windows错误代码查询</a></li><li><em></em><a href="/n/180591">激活windows有什么用</a></li><li><em></em><a href="/n/142370">Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Win</a></li><li><em></em><a href="/n/140347">Windows 10自动更新怎么关闭 如何关闭Windows 10自</a></li><li><em></em><a href="/n/136060">windows 10 rs4快速预览版17017下载错误问题</a></li><li><em></em><a href="/n/133896">Win10秋季创意者更新16291更新了什么 win10 16291</a></li> </ul> </section> <!-- 相同厂商 --> <section id="tcsyy" class="bottom_bor pictxt p10"> <p class="dtit"><span><a href="/company/0.html" style="background: none;margin:0;padding:0">更多+</a></span><b>相同厂商</b></p> <div id="tags-main1"> <div class="tags-main-ul"> </div></div> <div class="pagenum"></div> </section> <!-- 热门推荐 --> <section class="tjyxph bot_line p10 bottom_bor"> <p class="dtit"><b>热门<font class="ctitle"></font>推荐</b></p> <div class="dcatetory hot_game"></div> </section> <!-- 排行榜 --> <section class="bottom_bor rank p10"> <div class="d_title dtit"><div class="tab-panel d_title_r"><ul><li>最新排行</li><li class="active">最热排行</li><li>评分最高</li></ul></div><b><font class="ctitle"></font>排行榜</b></div> <div class="tab-content"> <div class="list"> <ul></ul></div><p class="lookmore" ><span>点击查看更多</span><i></i></p> </div> <div class="tab-content"> <div class="list"> <ul></ul></div><p class="lookmore" ><span>点击查看更多</span><i></i></p> </div> <div class="tab-content"> <div class="list"> <ul></ul></div><p class="lookmore" ><span>点击查看更多</span><i></i></p> </div> </section> <script>d()</script> <section class="cont pl new" id="comment"><p class="dtit"><s id="gocomment">说两句</s><b>网友评论</b></p> <div id="view-comment" class="reviews"><div class="post"><ul id="comment-list"></ul><footer class="button-status-complete"><input type="button" value="更多评论" class="button" style="display:none;" /></footer><header><span class="fb">我要评论...</span></header></div></div> <div id="submit" class="post"><fieldset class="w-text"><textarea onKeyUp="validate()"></textarea></fieldset><fieldset class="w-button"><input id="verify" class="button disable" type="submit" value="提交跟贴" hidefocus="true" /><span id="cancel" class="button">取消</span></fieldset><input type="hidden" id="app-id" value="1831" /><input type="hidden" value="1" name="CommentTpye" id="CommentTpye"></div> </section> <script>e()</script> <footer class="bottom" style="position: relative;"> <section class="footer_nav"> <ul> <li><a href="/article.html">资讯</a></li> <li><a href="/k.html">专题</a></li> <li><a href="/company.html">厂商</a></li> <li><a href="http://m.libao.pc6.com/">礼包</a></li> <li><a href="/ku.html">手游库</a></li> <li><a href="/znyj.html">智能</a></li> <li><a href="/">首页</a></li> <li><a href="/ruanj.html">应用</a></li> <li><a href="/ku.html">手游</a></li> <li><a href="/zt/top/az/">排行榜</a></li> <li><a href="/youxi.html">小游戏</a></li> <li class="arrow"></li> </ul> </section> <a id="goTop" href="#">返回顶部</a><p><a href="/map.html">网站地图</a>|<a href="/">返回首页</a></p> </footer> <script type="text/javascript"> var _webInfo = {};_webInfo={Username:"网络虫虫",Type:"1",DateTime:"2004/10/7 19:08:00",Id:"1831"}; </script> <script src="//msite.baidu.com/sdk/c.js?appid=1567067116007829"></script> <script type="application/ld+json"> { "@context": "https://zhanzhang.baidu.com/contexts/cambrian.jsonld", "@id": "https://m.pc6.com/n/1831", "appid": "1567067116007829", "title": "用ASP做一个TOP COOL的站内搜索", "description": "", "pubDate": "2004-10-07T19:08:00", "isOriginal": "1", "data": { "WebPage": { "headline": "用ASP做一个TOP COOL的站内搜索", "wapUrl": "https://m.pc6.com/n/1831", "pcUrl": "http://www.pc6.com/infoview/Article_1831.html", "tag": [ "windows" ], "commentCount": 2, "description": "", "datePublished": "2004-10-07T19:08:00", "domain": "电子科技", "category": [ "问答" ], "isDeleted": 0, "fromSrc": "PC6" }, "Question": [ { "acceptedAnswer": "" } ], "ImageObject": [ { "contentUrl": "", "scale": "5:2" } ], "Author": [ { "name": "PC6", "jobTitle": ["PC6"], "headPortrait": "https://thumb11.jfcdns.com/2018-08/17/bce5b761c4dbc6fd.jpeg" } ] } } </script> <script type="text/javascript" charset="UTF-8" src="/public/js/news.min.js"></script> </body> </html>