主题:  怎样改才能显示搜索得到的是文件名称或标题?

gf00si

职务:普通成员
等级:1
金币:1.0
发贴:156
#12002/4/3 20:15:06
这是我搜索引擎的源文件,但是它每次搜索得到的都是文件的地址,能不能让它显示的是文件名称或标题?

<%@ 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)



%>





<%'查找从这里开始
    fold root
%>


<%for i=1 to counter%>





<%next%>
你查找的关键字是:
<%=request("keyword")%>


共找到<%=counter%>个记录



<% =i%>
条记录










<%
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
%>

编辑历史:[这消息被deepdark编辑过(编辑时间2002-04-03 22:20:02)]


有饭

职务:普通成员
等级:2
金币:10.0
发贴:669
#22002/4/3 20:43:16

function searchFile (f,s,title)
set fo=fs.OpenTextFile(f)
content=fo.ReadAll
fo.close
searchFile=InStr(1, content, S, vbTextCompare)>0
If searchFile Then
pos1=InStr(1, content, "", vbTextCompare)<br> pos1=InStr(1, content, "<TITLE>", vbTextCompare)<br> title=""<br> If pos1>0 and pos2>0 then<br> title=Mid(content,pos1+7,pos2-pos1-7)<br> End if<br> End if<br>End Function<br></font> </div> <div class='edit_last'> <p align="right"> <br /> </p> </div> <div class="qianming"></div> </div> </td> </tr> <tr class='tr1'> <td valign="top" width='18%' class='threadUser'> <a target="_blank" href="http://gf00si.5d.cn/"><img class="small" src="http://res.5d.cn/heads/noface.gif"/><br/>gf00si</a><br /> 职务:普通成员<br /> 等级:1<br /> 金币:1.0<br /> 发贴:156<br/> </td> <td valign="top" class='threadInfo'> <div class='content_main'> <div class='edit'> <ul> <li><a id="_ctl0__ctl0_main_main_rptPosts__ctl2_btnQuote" href="/User/Posting.aspx?action=quote&forum=10&id=283429&id2=284512&id3=3">引用</a></li> <li></li> <li></li> </ul> </div> <div class='time'><span>#3</span>2002/4/4 22:56:40</div> <div class='content_c'> 多谢covien了,不过还是不行啊,你能不能给的再详细些!<br> </div> <div class='edit_last'> <p align="right"> <br /> </p> </div> <div class="qianming"></div> </div> </td> </tr> <tr class=''> <td valign="top" width='18%' class='threadUser'> <a target="_blank" href="http://covien.5d.cn/"><img class="small" src="http://res.5d.cn/heads/noface.gif"/><br/>有饭</a><br /> 职务:普通成员<br /> 等级:2<br /> 金币:10.0<br /> 发贴:669<br/> </td> <td valign="top" class='threadInfo'> <div class='content_main'> <div class='edit'> <ul> <li><a id="_ctl0__ctl0_main_main_rptPosts__ctl3_btnQuote" href="/User/Posting.aspx?action=quote&forum=10&id=283429&id2=285133&id3=4">引用</a></li> <li></li> <li></li> </ul> </div> <div class='time'><span>#4</span>2002/4/5 13:18:05</div> <div class='content_c'> 我没有去分析的代码!那么我的给你的那个函数我再给你分析一下吧!<br>其中传递的参数s为要搜索的字符串<br>“f”为找到的文件的文件名;<br>最后产生出来的Title变量就为Htm文件的标题!我的这些只是参考,你再按照的去改一下吧,注意其中的参数传递,和变量名! </div> <div class='edit_last'> <p align="right"> <br /> </p> </div> <div class="qianming"></div> </div> </td> </tr> </table> <div id="_ctl0__ctl0_main_main_Pager2" class="pages"><div class="quotes">每页显示15条 1/1<a disabled="true" class="disabled"><<</a><a disabled="true" class="disabled"><</a><span class="current">1</span><a disabled="true" class="disabled">>></a><input type="input" class="input" /><input type="button"/ class="go" value="GO" onclick="if(this.previousSibling.value && !isNaN(this.previousSibling.value)){location.href='?forum=10&id=283429&page={0}'.replace('{0}',this.previousSibling.value)}"></div></div> <table id="_ctl0__ctl0_main_main_QuickPostForm" class="FastRe mainTable"> <tr> <td valign="top" style="width:150px;"> <b></b> </td> <td valign="top"> <b>在 回复主题:怎样改才能显示搜索得到的是文件名称或标题?</b> </td> </tr> <tr> <td align="right"> </td> </tr> <tr> <td valign="top" nowrap="nowrap" align="right"> <b>正文:</b> </td> <td valign="top" class="fck"> <script type='text/javascript' src="/ubbeasy/UbbFun_v2.0.js" charset="gb2312" language='javascript'></script> <link href="/ubbeasy/i5D_editor.css" rel="stylesheet" type="text/css" /> <div id="ubbeditor"> <table class="btn_tools"> <tr> <td><img onclick="ubbFormat('b','要使用粗体的文字',EditMethod)" src="/ubbeasy/images/ico_Bold.gif" alt="加粗" /></td> <td><img onclick="ubbFormat('u','要使用下划线的文字',EditMethod)" src="/ubbeasy/images/ico_Underline.gif" alt="下划线" /></td> <td><img onclick="S(true,'SPC');" onmouseout="H(500,'SPC')" src="/ubbeasy/images/ico_color.gif" alt="文本颜色" /><table id="SPC" onmouseover="S(true,'SPC')" onmouseout="H(500,'SPC')" class="colorpalette" style="display:none;"> <tr> <td><a href="javascript:void(0);" onclick="chcolor('Black',EditMethod);H(0,'SPC');" style="background:Black"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('White',EditMethod);H(0,'SPC');" style="background:White"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Red',EditMethod);H(0,'SPC');" style="background:Red"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Yellow',EditMethod);H(0,'SPC');" style="background:Yellow"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> </tr> <tr> <td><a href="javascript:void(0);" onclick="chcolor('Gray',EditMethod);H(0,'SPC');" style="background:Gray"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Silver',EditMethod);H(0,'SPC');" style="background:Silver"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Maroon',EditMethod);H(0,'SPC');" style="background:Maroon"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Olive',EditMethod);H(0,'SPC');" style="background:Olive"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> </tr> <tr> <td><a href="javascript:void(0);" onclick="chcolor('Lime',EditMethod);H(0,'SPC');" style="background:Lime"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Aqua',EditMethod);H(0,'SPC');" style="background:Aqua"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Blue',EditMethod);H(0,'SPC');" style="background:Blue"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Fuchsia',EditMethod);H(0,'SPC');" style="background:Fuchsia"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> </tr> <tr> <td><a href="javascript:void(0);" onclick="chcolor('Green',EditMethod);H(0,'SPC');" style="background:Green"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Teal',EditMethod);H(0,'SPC');" style="background:Teal"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Navy',EditMethod);H(0,'SPC');" style="background:Navy"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> <td><a href="javascript:void(0);" onclick="chcolor('Purple',EditMethod);H(0,'SPC');" style="background:Purple"><img src="/ubbeasy/images/alpha.gif" alt="" /></a></td> </tr> </table></td> <td><img onclick="ubbFormat('center','居中对齐',EditMethod)" src="/ubbeasy/images/ico_center.gif" alt="居中" /></td> <td><img onclick="churl(EditMethod)" src="/ubbeasy/images/ico_link.gif" alt="插入链接" /></td> <td><img onclick="ubbFormat('Google','要搜索的关键词',EditMethod)" src="/ubbeasy/images/ico_googlelink.gif" alt="建立Google搜索链接" /></td> <td><img onclick="ubbFormat('img','要插入的图片的URL地址',EditMethod)" src="/ubbeasy/images/ico_image.gif" alt="插入图片" /></td> <td><img onclick="ubbFormat('quote','',EditMethod)" src="/ubbeasy/images/ico_quote.gif" alt="引用文本" /></td> </tr> </table> <DIV class=editor_text> <textarea onmouseup="checkMessage();" onkeyup="checkMessage();" onblur="checkMessage();" style="WIDTH: 600px; HEIGHT: 150px" name="Message" id="smallEditer" ></textarea> <div id='editor_status'> </div> </div> <div class="btn_face"> <img onclick="chFace(':e_han')" src="/ubbeasy/face/e_han.gif" alt="汗" /> <img onclick="chFace(':e_xin')" src="/ubbeasy/face/e_xin.gif" alt="喜欢" /> <img onclick="chFace(':e_xiao')" src="/ubbeasy/face/e_xiao.gif" alt="骄傲的笑" /> <!--<img onclick="chFace(':e_ganga')" src="/ubbeasy/face/e_ganga.gif" alt="尴尬" /> <img onclick="chFace(':e_shuijiao')" src="/ubbeasy/face/e_shuijiao.gif" alt="困了" />--> <img onclick="chFace(':e_ku')" src="/ubbeasy/face/e_ku.gif" alt="哭" /> <img onclick="chFace(':e_cool')" src="/ubbeasy/face/e_cool.gif" alt="酷!" /> <img onclick="chFace(':e_nu')" src="/ubbeasy/face/e_nu.gif" alt="愤怒" /> <img onclick="chFace(':e_heixian')" src="/ubbeasy/face/e_heixian.gif" alt="黑线" /> <img onclick="chFace(':e_wen')" src="/ubbeasy/face/e_wen.gif" alt="什么?" /> <img onclick="chFace(':e_shan')" src="/ubbeasy/face/e_shan.gif" alt="猥琐" /> <img onclick="chFace(':e_touxiao')" src="/ubbeasy/face/e_touxiao.gif" alt="偷笑" /> <img onclick="chFace(':e_wuyu')" src="/ubbeasy/face/e_wuyu.gif" alt="无语" /> <img onclick="chFace(':e_yun')" src="/ubbeasy/face/e_yun.gif" alt="晕" /> <img onclick="chFace(':e_chijing')" src="/ubbeasy/face/e_chijing.gif" alt="吃惊" /> <img onclick="chFace(':e_youhuo')" src="/ubbeasy/face/e_youhuo.gif" alt="诱惑" /> <br /> <IMG onclick='chFace(":)")' alt=smile src="/ubbeasy/face/smile.gif" border=0> <IMG onclick='chFace(":(")' alt=frown src="/ubbeasy/face/frown.gif" border=0> <IMG onclick='chFace(":o")' alt=redface src="/ubbeasy/face/redface.gif" border=0> <IMG onclick='chFace(":D")' alt=biggrin src="/ubbeasy/face/biggrin.gif" border=0> <IMG onclick='chFace(";)")' alt=wink src="/ubbeasy/face/wink.gif" border=0> <IMG onclick='chFace(":rolleyes:")' alt=rolleyes src="/ubbeasy/face/rolleyes.gif" border=0> <IMG onclick='chFace(":mad:")' alt=mad src="/ubbeasy/face/mad.gif" border=0> <IMG onclick='chFace(":eek:")' alt=eek src="/ubbeasy/face/eek.gif" border=0> <span class='cf_closesmile'><input class='cbox' type='checkbox' id='closesmile'/>禁止笑脸转换</span> </div> <script type='text/javascript' language='javascript' > //if(typeof(SetContentId)=="function") if(typeof(SetContentId)=='function') { SetContentId('smallEditer'); } </script> <script type='text/javascript' language='javascript' src='http://www.5d.cn/script/ValidatorScript.js' ></script> </div> <br/> <b>提示:</b>按 Ctrl+Enter 快速提交<br /> </td> </tr> <tr> <td colspan="2" align="center"> <input type="submit" name="_ctl0:_ctl0:main:main:btnSubmit" value=" 快速回复 " id="_ctl0__ctl0_main_main_btnSubmit" accesskey="A" />    <input type="submit" name="_ctl0:_ctl0:main:main:_ctl12" value=" 切换到完整回复 " /></td> </tr> </table> </div> </form> <script type="text/javascript"> $('a.delete').click(function(){ return confirm("删除后将不可还原,请再次确认"); }); var init_Script = function() { try { var o = GetContent(); o.style.width = '100%'; } catch (e) { } }; init_Script(); $('#aspnetForm').keyup(function(e) { if (e.ctrlKey && e.keyCode == 13) { $('#_ctl0__ctl0_main_main_btnSubmit').click(); } }); </script> <div style='margin:2px auto;border:#ccc solid 1px;text-align:center; width:972px;'> <script type="text/javascript"> google_ad_client = "pub-4239440736845119"; /* 728x90, 创建于 08-9-8 */ google_ad_slot = "0765827036"; google_ad_width = 728; google_ad_height = 90; </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div> </div> </div> <div class="i5D_footer"><a href="#">关于我们</a> | <a href="#">免责声明</a> | <a href="#">合作联系</a> | <a href="#">版权信息</a> | <a href="#">友情链接</a> | <a href="http://www.miibeian.gov.cn/CX/main.jsp"> ICP许可证:浙ICP备05007613号</a><br /> ©1999-2008 5D.cn. 版权所有 <br /> <a href="http://ulic.baidu.com/client/clientDetailCerInfo.do?id=914" target="_blank"> <img src="http://ulic.baidu.com/unlicpic/11448_green.gif" border="0" alt="百度大联盟认证绿色会员" /></a> </div> </body> </html>