如何做一个只搜索本网站的引擎?

栏目: 编程语言 · 发布时间: 6年前

内容简介:如何做一个只搜索本网站的引擎?

searchfiles.html 
<html>

<head>

<title>撼雪喷云之本网搜索引擎</title>

</head>

<body>

<form method="POST" action="cgi-bin/searchfiles.asp">

  <table border="0" cellpadding="5" bgcolor="#C2E7E3">

    <tr>

      <td align="center">请输入条目或关键词<input type="text" name="term" size="15"> <input  type="submit" value="搜索"></td>

    </tr>

  </table>

</form>

</body></html>

 

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 ("<CENTER><H2>
搜索结果</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>
搜索结果</title></head><body BGCOLOR=FFFFFF><CENTER>") 

Response.Write ("<TABLE BORDER=0 WIDTH=550><tr><td BGCOLOR=C0C0C0><FONT SIZE=5><B>
搜索结果</B></FONT></td></tr></TABLE>") 

Response.Write ("<TABLE BORDER=0 WIDTH=550>") 
if SearchResponse<>"" then 
Response.Write SearchResponse
else
Response.Write ("<tr><td>
对不起,没有找到你输入的条目或关键词!</td></tr>")
end if
Response.Write ("</TABLE>")

Response.Write ("<TABLE BORDER=0 WIDTH=550><tr><td BGCOLOR=C0C0C0 ALIGN=RIGHT><FONT SIZE=1>
现在调用专业搜索引擎<A HREF= http://www.yahoo.com.cn/ </A></FONT></td></tr></TABLE>")

' 任选一个你喜欢的引擎.

Response.Write ("</CENTER></body></html>")

End Sub
%>

 

 

[1]


以上所述就是小编给大家介绍的《如何做一个只搜索本网站的引擎?》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Convergence Culture

Convergence Culture

Henry Jenkins / NYU Press / 2006-08-01 / USD 30.00

"Convergence Culture" maps a new territory: where old and new media intersect, where grassroots and corporate media collide, where the power of the media producer, and the power of the consumer intera......一起来看看 《Convergence Culture》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

URL 编码/解码
URL 编码/解码

URL 编码/解码

RGB CMYK 转换工具
RGB CMYK 转换工具

RGB CMYK 互转工具