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]
发表评论