这是我搜索引擎的源文件,但是它每次搜索得到的都是文件的地址,能不能让它显示的是文件名称或标题?
<%@ Language=VBScript %>
<%option explicit%>
<% on error resume next %>
<% server.ScriptTimeout=300 %>
查找结果---关键字:<%=request("keyword")%>
<%
dim counter,keyword,fs,root,subpath,subpathlen,i
dim find_result(1024)
dim urlstr
urlstr=Server.MapPath("")
'---------------
if Request("keyword")="" then
Response.End
end if
'------------------
counter=0
keyword=Request("keyword")
Set fs = CreateObject("Scripting.FileSystemObject")
set root=fs.GetFolder (server.MapPath("/"))
subpath=server.MapPath("/")
subpathlen=len(subpath)
%>
你查找的关键字是: |
<%=request("keyword")%> |
<%'查找从这里开始
fold root
%>
共找到<%=counter%>个记录 |
<%for i=1 to counter%>
第 <% =i%> 条记录 |
|
|
<%next%>
<%
function fold(byref obj)
dim folder,file,pos,tmp,thisfile,str
for each folder in obj.subfolders
'Response.Write folder.name&"
"
for each file in folder.files
if instr(1,file.name,".htm") or instr(1,file.name,".html") then
Set thisfile = fs.OpenTextFile(file.path,1,False)
str=thisfile.readall
pos= instr(1,str,keyword)
thisfile.close
if pos>0 then
tmp=replace(file.path,subpath,urlstr)
counter = counter + 1
find_result(counter)=tmp
end if
end if
next
fold folder
next
end function
%>