文本搜索
搜索 文本
2023-06-13 09:13:46 时间
<%
Head="搜索"
SearchString=Request("SearchString")
count=0
"把当前目录的实际路径转换为虚拟路径
FunctionUnMapPath(Path)
UnMapPath=Replace(Mid(Path,Len(Server.MapPath("/"))+1),"\","/")
EndFunction
FunctionSearchFile(f,s,title)
Setfo=fs.OpenTextFile(f)
content=fo.ReadAll"读全部文本到content
fo.Close
SearchFile=InStr(1,content,S,vbTextCompare)>0"从第一个字符开始检查content里面是否有S
IfSearchFileThen"如果有,则提出文件TITLE存入变量
pos1=InStr(1,content,"<TITLE>",vbTextCompare)
pos2=InStr(1,content,"</TITLE>",vbTextCompare)
title=""
Ifpos1>0Andpos2>0Then"取TITLE标记中间的字符
title=Mid(content,pos1+7,pos2-pos1-7)
EndIf
EndIf
EndFunction
FunctionFileLink(f,title)
vPath=UnMapPath(f.Path)"取路径
Iftitle=""Thentitle=f.Name"做链接
FileLink="<AHREF="""&vPath&""">"&title&"</A>"
FileLink="<UL>·"&FileLink&"</UL>"
EndFunction
SubSearchFolder(fd,s)
found=False
ForeachfInfd.Files
pos=InStrRev(f.Path,".")
Ifpos>0Then
ext=Mid(f.Path,pos+1)
Else
ext=""
EndIf
IfLCase(ext)="htm"Then"显示扩展名字为HTM的文件
IfSearchFile(f,s,title)Then
Response.WriteFileLink(f,title)
count=count+1
"Response.Writecstr(count)
EndIf
EndIf
Next
ForeachsfdInfd.SubFolders
SearchFoldersfd,s
Next
EndSub
%>
<html>
<head>
<metahttp-equiv="Content-Type"
content="text/html;charset=gb_2312-80">
<metaname="GENERATOR"content="MicrosoftFrontPageExpress2.0">
<title><%=Head%></title>
</head>
<bodybgcolor="#FFFFFF">
<h1><%=Head%></h1>
<hr>
<formaction="search.asp"method="Get">
<p>请输入欲搜索的内容:<inputtype="text"
size="20"name="SearchString"value="<%=SearchString%>"><input
type="submit"value="搜索"></p>
</form>
<%
Setfs=Server.CreateObject("Scripting.FileSystemObject")
Setfd=fs.GetFolder(Server.MapPath("/"))"设置开始搜索的路径!
IfSearchString<>""Then
Response.Write"<H2>搜索<fontcolor=red>"&SearchString&"</font>结果如下:</H2><P>"
SearchFolderfd,SearchString
EndIf
%>
<hr>
</body>
</html>
Head="搜索"
SearchString=Request("SearchString")
count=0
"把当前目录的实际路径转换为虚拟路径
FunctionUnMapPath(Path)
UnMapPath=Replace(Mid(Path,Len(Server.MapPath("/"))+1),"\","/")
EndFunction
FunctionSearchFile(f,s,title)
Setfo=fs.OpenTextFile(f)
content=fo.ReadAll"读全部文本到content
fo.Close
SearchFile=InStr(1,content,S,vbTextCompare)>0"从第一个字符开始检查content里面是否有S
IfSearchFileThen"如果有,则提出文件TITLE存入变量
pos1=InStr(1,content,"<TITLE>",vbTextCompare)
pos2=InStr(1,content,"</TITLE>",vbTextCompare)
title=""
Ifpos1>0Andpos2>0Then"取TITLE标记中间的字符
title=Mid(content,pos1+7,pos2-pos1-7)
EndIf
EndIf
EndFunction
FunctionFileLink(f,title)
vPath=UnMapPath(f.Path)"取路径
Iftitle=""Thentitle=f.Name"做链接
FileLink="<AHREF="""&vPath&""">"&title&"</A>"
FileLink="<UL>·"&FileLink&"</UL>"
EndFunction
SubSearchFolder(fd,s)
found=False
ForeachfInfd.Files
pos=InStrRev(f.Path,".")
Ifpos>0Then
ext=Mid(f.Path,pos+1)
Else
ext=""
EndIf
IfLCase(ext)="htm"Then"显示扩展名字为HTM的文件
IfSearchFile(f,s,title)Then
Response.WriteFileLink(f,title)
count=count+1
"Response.Writecstr(count)
EndIf
EndIf
Next
ForeachsfdInfd.SubFolders
SearchFoldersfd,s
Next
EndSub
%>
<html>
<head>
<metahttp-equiv="Content-Type"
content="text/html;charset=gb_2312-80">
<metaname="GENERATOR"content="MicrosoftFrontPageExpress2.0">
<title><%=Head%></title>
</head>
<bodybgcolor="#FFFFFF">
<h1><%=Head%></h1>
<hr>
<formaction="search.asp"method="Get">
<p>请输入欲搜索的内容:<inputtype="text"
size="20"name="SearchString"value="<%=SearchString%>"><input
type="submit"value="搜索"></p>
</form>
<%
Setfs=Server.CreateObject("Scripting.FileSystemObject")
Setfd=fs.GetFolder(Server.MapPath("/"))"设置开始搜索的路径!
IfSearchString<>""Then
Response.Write"<H2>搜索<fontcolor=red>"&SearchString&"</font>结果如下:</H2><P>"
SearchFolderfd,SearchString
EndIf
%>
<hr>
</body>
</html>
相关文章
- 无人机集群自组织搜索仿真模型设计与实现
- SuperSearch(超级网搜) – 更名为 AllWebSearch《全网搜索 6.0》 – 让思考从搜索开始
- 记忆化搜索(Memory Search)
- 【搜索】八皇后「建议收藏」
- PaddleNLP基于ERNIR3.0文本分类以中医疗搜索检索词意图分类(KUAKE-QIC)为例【多分类(单标签)】
- 关键词搜索1688商品接口,1688商品列表接口,1688商品销量排序接口,1688商品价格排序接口代码分享
- 不会写国自然摘要,来看看如何搜索优秀摘要模板~
- Python tkinter 制作文章搜索软件,有没有方便快捷不知道,好玩就行了
- 研发效能提升:vivo AI 搜索平台化建设
- MongoDB学习之Text Search文本搜索功能
- linux最快的文本搜索神器ripgrep(grep的最好代替者)
- Oracle 模糊搜索: 找到你要的结果(oracle模糊搜索)
- grep命令_Linux grep命令:文本搜索工具(可使用正则表达式)
- 利用Linux egrep实现快速文本搜索(linuxegrep)
- Linux文本中的强大搜索功能(linux在文本中搜索)
- Lynx在过去很长一段时间被认为是最好的浏览器,但是其巅峰时期已经过去了。这款基于文本的浏览器需要通过终端视窗查看,如果使用GUI服务器进行网络搜索,那么Lynx这类工具就必不可少了。不过它和标准浏览器不一样,不能点击链接,也不能看图片,当然更不用提Flash或Java小程序了。
- MySQL索引:精准搜索的算法之路(mysql索引的算法)
- 什么SQL Server分页技术:利用它实现数据精准搜索(sqlserver分页是)
- Linux下grep:强大的文本搜索工具(linux 下grep)
- Redis改变搜索传统,提高效率(搜索能用redis)
- PHP文本数据库的搜索方法
- javascript自动标记来自搜索结果页的关键字
- javascript搜索框点击文字消失失焦时文本出现