当前位置: 代码网 > it编程>编程语言>其他编程 > 如何做一个只搜索本网站的引擎?

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

2024年05月18日 其他编程 我要评论
searchfiles.html<html><head><title>撼雪喷云之本网搜索引擎</title></head><body&

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]

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com