如何做一個只搜索本網(wǎng)站的引擎?
searchfiles.html 
<html>
<head>
<title>撼雪噴云之本網(wǎng)搜索引擎</title>
</head>
<body>
<form method="POST" action="cgi-bin/searchfiles.asp">
<table border="0" cellpadding="5" bgcolor="#C2E7E3">
<tr>
<td align="center">請輸入條目或關(guān)鍵詞<input type="text" name="term" size="15"> <input type="submit" value="搜索"></td>
</tr>
</table>
</form>
</body></html>
 <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
searchfiles.asp
<% 
SearchTerm = request.form("term") 
Novalid=" a b c d e f g h i j k l m n o p q r s t u v w x y z yes no and more" 
NovalidResponse ="你輸入的內(nèi)容過于簡單,請返回重試!" 
if instr(SearchTerm,Novalid)=0 then 
Response. Write ("<CENTER><H2>搜索結(jié)果</H2></CENTER>") 
  FolderName= "FolderName" 
  ShowList() 
else 
Response.Write NovalidResponse 
End if 
SearchResponse="" 
%> 
<% 
Sub ShowList() 
FolderToCheck = server.mappath("\") &"/" & FolderName & "/" 
Dim fs, f, f1, fc, s 
    Set fs = CreateObject("Scripting.FileSystemObject") 
    Set f = fs.GetFolder(FolderToCheck) 
Set fc = f.Files 
For Each f1 in fc 
        Wfile = f1.name 
          if right(Wfile, 5)=".html" OR right(Wfile, 4)=".htm" then 
            Wfile2 = FolderToCheck & Wfile 
            Set fs = CreateObject("Scripting.FileSystemObject") 
            Set a = fs.OpenTextFile(Wfile2) 
            ct = a.ReadAll 
            a.close 
            ct2=lcase(ct) 
            SearchTerm2 = lcase(SearchTerm) 
                  if instr(ct2,SearchTerm2)>0 then 
                      if instr(ct,"</title>")>0 then 
                  longitud=instr(ct,"</title>") 
                  longitud=longitud -1 
                          ct=left(ct,longitud) 
                          longitud2=len(ct) 
                  longitud=instr(ct,"<title>") 
                  longitud=longitud2 -longitud -6 
                          ct=right(ct,longitud) 
                    else 
                        if instr(ct,"</title>")>0 then 
                    longitud=instr(ct,"</title>") 
                    longitud=longitud -1 
                            ct=left(ct,longitud) 
                            longitud2=len(ct) 
                    longitud=instr(ct,"<title>") 
                    longitud=longitud2 -longitud -6 
                            ct=right(ct,longitud) 
            end if 
                    end if 
                    SearchResponse= SearchResponse +"<tr><td>"+ ct + "</td><td ALIGN=CENTER 
VALIGN=MIDDLE>" + " <A HREF=" + "/" + FolderName + "/" + Wfile +"> More </A></td></tr>" 
          longitud=0 
                  ct="" 
                  end if 
          end if 
Next 
Response.Write ("<html><head><title>搜索結(jié)果</title></head><body BGCOLOR=FFFFFF><CENTER>")  
Response.Write ("<TABLE BORDER=0 WIDTH=550><tr><td BGCOLOR=C0C0C0><FONT SIZE=5><B>搜索結(jié)果</B></FONT></td></tr></TABLE>")  
Response.Write ("<TABLE BORDER=0 WIDTH=550>")  
if SearchResponse<>"" then  
Response.Write SearchResponse 
else 
Response.Write ("<tr><td>對不起,沒有找到你輸入的條目或關(guān)鍵詞!</td></tr>") 
end if 
Response.Write ("</TABLE>") 
Response.Write ("<TABLE BORDER=0 WIDTH=550><tr><td BGCOLOR=C0C0C0 ALIGN=RIGHT><FONT SIZE=1>現(xiàn)在調(diào)用專業(yè)搜索引擎<A HREF= http://www.yahoo.com.cn/ </A></FONT></td></tr></TABLE>") 
' 任選一個你喜歡的引擎.
Response.Write ("</CENTER></body></html>") 
End Sub 
%>
 
 
[1]
欄 目:編程問答
本文標(biāo)題:如何做一個只搜索本網(wǎng)站的引擎?
本文地址:http://www.jygsgssxh.com/a1/bianchengwenda/12076.html
您可能感興趣的文章
- 01-11如何實現(xiàn)點擊數(shù)的計算?
 - 01-11如何判斷電子郵件的地址格式是否正確?
 - 01-11如何做一個文本搜索?
 - 01-11如何實現(xiàn)網(wǎng)上考試?
 - 01-11如何實現(xiàn)全文檢索?
 - 01-11如何用POP3接收電子郵件?
 - 01-11如何使用表單發(fā)送電子郵件?
 - 01-11如何在線更改密碼?
 - 01-11如何取回已忘記的密碼?
 - 01-11如何做一個隨機密碼產(chǎn)生器?
 


閱讀排行
本欄相關(guān)
- 01-11如何實現(xiàn)點擊數(shù)的計算?
 - 01-11如何做一個文本搜索?
 - 01-11如何判斷電子郵件的地址格式是否正
 - 01-11如何實現(xiàn)全文檢索?
 - 01-11如何實現(xiàn)網(wǎng)上考試?
 - 01-11如何使用表單發(fā)送電子郵件?
 - 01-11如何用POP3接收電子郵件?
 - 01-11如何取回已忘記的密碼?
 - 01-11如何在線更改密碼?
 - 01-11如何做一個隨機密碼產(chǎn)生器?
 
隨機閱讀
- 04-02jquery與jsp,用jquery
 - 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
 - 08-05織夢dedecms什么時候用欄目交叉功能?
 - 01-10C#中split用法實例總結(jié)
 - 01-10delphi制作wav文件的方法
 - 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
 - 08-05DEDE織夢data目錄下的sessions文件夾有什
 - 01-11ajax實現(xiàn)頁面的局部加載
 - 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
 - 01-10使用C語言求解撲克牌的順子及n個骰子
 


