您现在的位置是:网站首页> 编程资料编程资料

如何做一个只搜索本网站的引擎?_编程10000问_

2023-05-25 139人已围观

简介 如何做一个只搜索本网站的引擎?_编程10000问_

searchfiles.html 

</span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">撼雪喷云之本网搜索引擎</span><span lang="EN-US">

 

   

     

   

 

请输入条目或关键词 type="submit" value="搜索">

 

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 ="
你输入的内容过于简单,请返回重试!"

if instr(SearchTerm,Novalid)=0 then
Response. Write ("

搜索结果

")

  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,"")>0 then
                  longitud=instr(ct,"")
                  longitud=longitud -1
                          ct=left(ct,longitud)
                          longitud2=len(ct)
                  longitud=instr(ct,"") <br>                  longitud=longitud2 -longitud -6 <br>                          ct=right(ct,longitud) <br>                    else <br>                        if instr(ct,"")>0 then
                    longitud=instr(ct,"")
                    longitud=longitud -1
                            ct=left(ct,longitud)
                            longitud2=len(ct)
                    longitud=instr(ct,"") <br>                    longitud=longitud2 -longitud -6 <br>                            ct=right(ct,longitud) <br>            end if <br>                    end if <br><br>                    SearchResponse= SearchResponse +"<tr><td>"+ ct + "</td><td ALIGN=CENTER <br>VALIGN=MIDDLE>" + " <A HREF=" + "/" + FolderName + "/" + Wfile +"> More </A></td></tr>" <br>          longitud=0 <br>                  ct="" <br><br>                  end if <br>          end if <br><br>Next <br><br>Response.Write ("<html><head><title></span><span style="FONT-FAMILY: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'">搜索结果</span><span lang="EN-US">
") 

Response.Write ("
搜索结果
") 

Response.Write ("") 
if SearchResponse<>"" then 
Response.Write SearchResponse
else
Response.Write ("
对不起,没有找到你输入的条目或关键词