怎么用asp做全文检索?给点思路也好

ebombsuhocom 2003-08-22 06:10:49
我要做一个ASP全文搜索,搜索的内容即有目前存在的网页,也有数据库里的东西(把网页的源文件放到了数据库里),有什么好点的方法?或者是那方有些书可以参考一下。
...全文
95 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
凯晰叶子 2003-08-23
  • 打赏
  • 举报
回复
用ASP建立站内搜索
(一),首先利用access97建立一个名为list.mdb的数据库,在里面建立一个名为list的表,然后在list表里面输入一些你想要被查询的文件名字,关键的搜索词还有相对应的链接,下面建立了四个项目ID(编号),title(主题),word(关键词),url(链接地址),如下表所示:IDtitle
word
url
1
cgi教程本地调试cgicgi/testcgi.htm
2
下载中心聊天室,留言本
download/index.htm (二),建立了数据库以后就可以建立你的asp搜索页面了,下面是一个文件名为search.htm的asp搜索页面的源程序,这个搜索引擎可以同时搜索title和word里面的内容,当然如果你有需要的话可以建立更多的搜索: <!--#INCLUDE file="ADOVBS.inc"-->
<% "建立数据库的连接
con="DBQ="+server.mappath("list.mdb")+";DefaultDir=;DIRVER={microsoft Access Driver(*.mdb)};"
"建立CONNECTION对象并打开数据库
set mycon=server.createobject("ADODB.CONNECTION")
mycon.open.con %>
"创建Recordset对象的例程,打开Recordset对象传递SQL串以及所有的连接信息
<% set rs=server.createobject("ADODB.Recordset")
rs.open "SELECT*FORM list where title and word like '%'&request.form("word")&"%'",MyCon,adOpenStatie
%>
"建立查询后的显示信息和查询页面,你想取什么名字都可以
<html><head><title>查询结果</title></head>
<body bgcolor="#ffffff">
<p align="center"><br>
"统计查询共有<% Response.Write(RS.RecordCount) %>条纪录</p><br>
<div align="center"><center>
<table border="1" align="center" bordercolor="000000" berdorcoorlight="#000000" bordercolordark="#ffffff">
<tr align="center">
<td width="20%" align="center" bgcolor="#ffffff">ID</td>
<td width="60%" align="center" bgcolor="#ffffff">主题</td>
<td width="20%" align="center" bgcolor="#ffffff">查看</td></table>
<table border="1" align="center" bordercolor="000000" berdorcoorlight="#000000" bordercolordark="#ffffff">
<tr align="center">
<!--从数据库提取信息-->
<% while not rs.eof %>
<tr align="center">
<td width="20%" align="center" bgcolor="#ffffff"><% =rs("id") %></td>
<td width="60%" align="center" bgcolor="#ffffff"><% =rs("title") %></td>
<td width="20%" align="center" bgcolor="#ffffff"><a href="<% =rs("url") %>">GO</a></td>
<% rs.movenext %></tr> <% wend %></table></center></div><% rs.close %>
<% mycon.close %>
"关闭链接
</body></html>
下面我们来建立搜索页面
<html><head><title>搜索页面</title></head>
<!--创建搜索表格-->
<from method="POST" action="search.asp">
<div align="center"><center><p><input type="text" name="word" size="30">
<input type="submit" value="提交" name="B1"><input type="reset" value="清除" name="B2"></p>
</center></div></form>
<hr width="600" align="center">
<html>
好了,这个站内搜索引擎到这里就算完成了,你接下来要做的就是吧东西输入数据库了!
凯晰叶子 2003-08-23
  • 打赏
  • 举报
回复
<%
Response.Buffer=True

Const ValidFiles = "htmltxt"
Const RootFld = "./"

Dim Matched
Dim Regex
Dim GetTitle
Dim fs
Dim rfLen
dim RootFolder
Dim DocCount
Dim DocMatchCount
Dim MatchedCount

' ----------------------------------------------
' Procedure: SearchFiles()
' ----------------------------------------------
Public Sub SearchFiles(FolderPath)
Dim fsFolder
Dim fsFolder2
Dim fsFile
Dim fsText
Dim FileText
Dim FileTitle
Dim FileTitleMatch
Dim MatchCount
Dim OutputLine

' Get the starting folder
Set fsFolder = fs.GetFolder(FolderPath)
' Iterate thru every file in the folder
For Each fsFile In fsFolder.Files
' Compare the current file extension with the list of valid target files
If InStr(1, ValidFiles, Right(fsFile.Name, 3), vbTextCompare) > 0 Then
DocCount = DocCount + 1
' Open the file to read its content
Set fsText = fsFile.OpenAsTextStream
FileText = fsText.ReadAll
' Apply the regex search and get the count of matches found
MatchCount = Regex.Execute(FileText).Count
MatchedCount = MatchedCount + MatchCount
If MatchCount > 0 Then
DocMatchCount = DocMatchCount + 1
' Apply another regex to get the html document's title
Set FileTitleMatch = GetTitle.Execute(FileText)
If FileTitleMatch.Count > 0 Then
' Strip the title tags
FileTitle = Trim(replace(Mid(FileTitleMatch.Item(0),8),"</title>","",1,1,1))
' In case the title is empty
If FileTitle = "" Then
FileTitle = "No Title (" & fsFile.Name & ")"
End If
Else
' Create an alternate entry name (if no title found)
FileTitle = "No Title (" & fsFile.Name & ")"
End If
' Create the entry line with proper formatting
' Add the entry number
OutputLine = "  <b>" & DocMatchCount & ".</B> "
' Add the document name and link
OutputLine = OutputLine & "<A href=" & chr(34) & RootFld & replace(Mid(fsFile.Path,
rfLen),"\","/") & chr(34) & "><B>"
OutputLine = OutputLine & FileTitle & "</B></a>"
' Add the document information
OutputLine = OutputLine & "<font size=1><br>  Criteria matched " & MatchCount
& " times - Size: "
OutputLine = OutputLine & FormatNumber(fsFile.Size / 1024,2 ,-1,0,-1) & "K bytes"
OutputLine = OutputLine & " - Last Modified: " & formatdatetime
(fsFile.DateLastModified,vbShortDate) & "</Font><br>"
' Display entry
Response.Write OutputLine
Response.Flush
End If
fsText.Close
End If
Next

' Iterate thru each subfolder and recursively call this procedure
For Each fsFolder2 In fsFolder.SubFolders
SearchFiles fsFolder2.Path
Next

Set FileTitleMatch = Nothing
Set fsText = Nothing
Set fsFile = Nothing
Set fsFolder2 = Nothing
Set fsFolder = Nothing
End Sub

' ----------------------------------------------
' Procedure: Search()
' ----------------------------------------------
Sub Search(SearchString)
Dim i
Dim fKeys
Dim fItems

Set fs = CreateObject("Scripting.FileSystemObject")
Set GetTitle = New RegExp
Set Regex = New RegExp

With Regex
.Global = True
.IgnoreCase = True
.Pattern = Trim(SearchString)
End With
With GetTitle
.Global = False
.IgnoreCase = True
.Pattern = "<title>(.|\n)*</title>"
End With

RootFolder = Server.MapPath(RootFld)

If Right(RootFld,1) <> "/" Then
RootFld = RootFld & "/"
End If

If Right(RootFolder, 1) <> "\" Then
RootFolder = RootFolder & "\"
End If
rfLen = Len(RootFolder) + 1

SearchFiles RootFolder

If MatchedCount = 0 Then
Response.Write "  <B>No Matches Found.</b><BR>"
End If

Set Regex = Nothing
Set GetTitle = Nothing
Set fs = Nothing

End Sub

%>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta http-equiv="Content-Language" content="en-us">
<TITLE>OneFile Search 1.0</TITLE>
</HEAD>
<body bgcolor="#FFFFFF" link="#660000" vlink="#008000">
<Font Face="Tahoma,Arial" Size="2">
<table border="0" width="100%" cellspacing="0" cellpadding="0">
<tr>
<td width="100%" colspan="2"></td>
</tr>
<tr>
<td width="50%" bgcolor="#000000">
<Form method="Get">
<table border="0" width="100%">
<tr>
<td width="33%" align="right"><font color="#FFFFFF" size="2" face="Tahoma,Arial"><b>Search
for </b></font></td>
<td width="33%"><input type="text" size="20" value="<%=Request.QueryString("query")%>"
name="query"></td>
<td width="34%"><input type="submit" name="Search" Value="Search"></td>
</tr>
</table>
</Form>
</td>
<td width="50%" bgcolor="#000000"></td>
</tr>
<tr>
<td width="100%" colspan="2" bgcolor="#000000"></td>
</tr>
<tr>
<td width="50%" bgcolor="#808080">
<table border="0" width="100%">
<tr>
<td width="33%" align="right"><font face="Tahoma,Arial" size="1"
color="#FFFFFF"><b>Tip:</b></font></td>
<td width="67%"><font color="#FFFFFF" face="Tahoma,Arial" size="1">Search by using <a
href="http://msdn.microsoft.com/scripting/default.htm /scripting/VBScript/doc/jsgrpregexpsyntax.htm">Regula
r Expresions</a>.</font></td>
</tr>
</table>
</td>
<td width="50%" bgcolor="#808080"></td>
</tr>
</table>

<%
If Trim(Request.QueryString("query")) <> "" Then
%>
<hr>
<table border="0" width="100%" bgcolor="#808080" cellspacing="0" cellpadding="0">
<tr>
<td width="100%"><Font Color="#FFFFFF" Size="2">  Your search for <B><%
=Request.QueryString("query")%></B> found the following documents:</Font></td>
</tr>
</table>
<BR><BR>
<%
Response.Flush
Search Request.QueryString("query")
If DocCount > 0 Then
%>
<BR>
<Font Size=1>
  (The search criteria "<%=Request.QueryString("query")%>" found <%=MatchedCount%> times in <%
=DocMatchCount%> of <%=DocCount%> documents.)
</font>
<%
End If
End If
%>
<BR><BR>
<hr><div align="center">
<Font size=1>
OneFile Search Engine v1.0<br>
Copyright 000 <a href="mailto:sixtos@prtc.net">Sixto Luis Santos</a>.
All Rights Reserved
</Font></div>

</Font>
</body>
</html>

<%
Response.End
%>
fuzq 2003-08-23
  • 打赏
  • 举报
回复
select * from table where detail like '%你的字符串%'
panyee 2003-08-22
  • 打赏
  • 举报
回复
用全文检索, 还可以检索word, excel等二进制的文本内容, 功能还是比较强

启动index服务, 不用表也可以直接检索硬盘上文件内容
就像搜索里有查"包含文字"一样
hzqq 2003-08-22
  • 打赏
  • 举报
回复
select * from table where detail like '%你的字符串%'
lions911 2003-08-22
  • 打赏
  • 举报
回复
既然都放到了数据库里面
用LIKE不就可以查询了?
panyee 2003-08-22
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/1594/1594455.xml?temp=.7930567
把网页文件放在表中, 字段要有存扩展名,文件类型文件长度,文件信息,文件名等..
**ASP局域网文件共享及检索系统设计与开发** 随着信息技术的飞速发展,文件共享和检索在企事业单位、教育机构等多个领域变得日益重要。为了满足这一需求,本资源提供了一个基于ASP(Active Server Pages)的局域网文件共享及检索系统的设计与开发方案。该方案旨在提供一个高效、安全且易于管理的文件共享平台,同时实现对局域网内文件的快速检索。 **系统特**: 1. **B/S架构**:系统采用浏览器/服务器架构,用户无需安装客户端软件,只需通过浏览器即可访问系统,大大降低了使用难度和维护成本。 2. **文件共享**:支持用户上传、下载和管理文件,可设置不同的访问权限,确保文件的安全性和隐私性。 3. **全文检索**:系统内置全文搜索引擎,可对局域网内的所有文件进行快速检索,支持关键词搜索、模糊搜索等多种检索方式。 4. **用户管理**:提供用户注册、登录、权限管理等功能,确保系统的安全性。 5. **日志记录**:系统自动记录用户的操作日志,方便管理员对系统进行监控和管理。 6. **二次开发定制**:系统采用模块化设计,方便进行二次开发和定制,满足不同用户的个性化需求。 **适用场景**: 本系统适用于需要实现文件共享和检索的局域网环境,如企事业单位内部文件管理、教育机构教学资源共享等。通过本系统,用户可以轻松实现文件的上传、下载、管理和检索,提高工作效率和学习效果。 **技术实现**: 系统基于ASP技术构建,结合HTML、CSS、JavaScript等前端技术和SQL Server数据库,实现了文件共享、检索、用户管理等功能。系统采用三层架构设计,包括表示层、业务逻辑层和数据访问层,确保了系统的稳定性和可扩展性。 **源代码及论文**: 本资源提供了完整的源代码和相关论文资料,方便用户进行二次开发和定制。源代码结构清晰、注释详细,便于理解和修改。论文资料详细介绍了系统的设计思路、实现方法和关键技术,为用户提供了全面的技术支持和参考。 总之,本资源提供了一个功能完善、安全可靠的局域网文件共享及检索系统解决方案,具有很高的实用价值和推广价值。
**计算机专业毕设精选:ASP.NET图像检索技术毕业设计** 本资源提供了一个全面且深入的ASP.NET图像检索技术毕业设计项目,包含了从源代码到论文、开题报告、外文翻译、文献综述以及答辩PPT的所有内容。该项目旨在帮助计算机专业的学生掌握图像检索技术的核心原理和实现方法,并通过实践应用来提升编程能力和解决实际问题的能力。 在源代码方面,本项目采用了先进的ASP.NET框架进行开发,实现了用户友好的界面和高效的图像检索算法。学生可以在理解源代码的基础上,根据实际需求进行二次开发和定制,以满足不同的应用场景需求。 论文部分则详细阐述了项目的背景、意义、技术路线和实现细节,为学生提供了一个完整的学术研究过程体验。同时,开题报告和外文翻译等内容也帮助学生更好地了解了项目的整体框架和研究思路。 此外,本资源还包含了丰富的文献综述资料,涵盖了图像检索技术的国内外研究现状和发展趋势,为学生提供了深入学习和研究的参考资料。 答辩PPT则是专门为毕业设计答辩而设计的,通过简洁明了的演示文稿,帮助学生向评审专家和同学们展示自己的研究成果和项目亮。 总之,本资源为计算机专业的学生提供了一个全方位、立体化的毕业设计支持体系,不仅有助于完成高质量的毕业设计作品,还能为学生未来的学术研究和职业发展打下坚实的基础。

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧