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

ebombsuhocom 2003-08-22 06:10:49
我要做一个ASP全文搜索,搜索的内容即有目前存在的网页,也有数据库里的东西(把网页的源文件放到了数据库里),有什么好点的方法?或者是那方有些书可以参考一下。
...全文
165 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
把网页文件放在表中, 字段要有存扩展名,文件类型文件长度,文件信息,文件名等..
打开链接下载源码: https://pan.quark.cn/s/589796089f72 C++课程设计任务列表,涵盖以下内容:1、识别并显示10至99范围内,各位数乘积超过各位数和的数值,例如数字12不满足条件,因为1乘以2小于1加2,故不输出;而数字27满足条件,因为2乘以7大于2加7,因此需要输出该数。2、开发一个功能,用于从用户输入的任意数量实数中找出最大值与最小值:首先要求用户输入一个正整数n,代表数值的个数,随后用户可输入任意n个实数,程序需找出这n个数中的最大值和最小值并将它们展示出来。3、实现两个已排序数组的合并操作:设有数组A和B,且假设这两个数组的元素均已按照降序排列。编写程序将A和B合并成一个新的数组C,并确保C中的元素同样保持降序排列。int A[10]={123, 86,80, 49,33,15,7,0,-1,-3};int B[10]={100,64,51,50,27,19,15,12,5,2};4、设计一个函数,用于计算特定分数序列前n项的总和,该序列为1/2,1/3,1/4,1/5,1/6,1/7,...。要求在主程序中提示用户输入一个整数n,并验证输入的合法性(n需大于1方为有效),若输入合法,则调用求和函数并显示计算结果。5、编写一个程序,计算两个用户输入日期之间的天数差:用户需以year1,month1,day1和year2,month2,day2的格式输入两个日期,程序随后计算这两个日期之间的天数间隔,并将结果输出到屏幕上。要求编制具有如下原型的函数difs2Date:long GetDayDifference(int y1,int m1,int d1,int y2,int m2,int d2);并在主函数中调用此函数,将计...
代码下载地址: https://pan.quark.cn/s/ee8627e4e6d7 ABAP调试器是一种功能强大的工具,可用于在执行期间对ABAP代码进行检验。除了常规的核心功能(例如逐行运行代码以及检验变量、字段符号和引用的值)之外,它还提供了一些辅助性的特性,能够简化并压缩调试会话的时长。并非所有使用者都熟悉这些辅助特性。SAP ABAP调试器是处理和优化ABAP代码开发与维护工作的核心资源,它配备了多样的功能来协助开发人员在运行状态下进行检验和排除故障。此资源着重阐述了ABAP调试器的一些高级特性,涵盖了深入分析调用堆栈、系统级调试、更新会话调试以及提升调试效率的方法。 1. **深入分析调用堆栈**:除了常规的应用程序调试,开发人员有时需要对调用堆栈的内部层级进行深入调试,特别是在错误出现在异步执行的更新处理或系统级程序时。通过启用**系统级调试**,可以访问通常不公开的系统代码,但这也会导致调用堆栈的显著增加,因此需要审慎操作。 2. **系统级调试**:对于不含业务逻辑的系统级程序,开发人员通常无需进行调试。然而,在特定情形下,例如进行错误追踪时,可能需要进入系统代码。借助调试器的“系统调试启用/禁用”选项,可以赋予对系统程序的调试权限。 3. **更新会话调试**:在处理异步更新任务,例如持久化业务数据时,错误可能发生在更新任务内部。激活**更新会话调试**,在更新任务完成后,调试器将自动启动,展示执行路径。比如,在变更成本中心后,通过输入调试指令 "/h" 启动调试,保存后能够看到更新过程中的错误。 4. **分析调用堆栈**:在进行深入调试时,调用堆栈是至关重要的。通过分析调用堆栈,能够定位到引发问题的具体位置,如在VB_V2_NORMAL...
源码链接: https://pan.quark.cn/s/a4b39357ea24 小程序雷达 AI 驱动的小程序生态选型与风险评估工具,把微信小程序开发资源转化为可筛选、可评估、可对比的技术雷达。 线上地址 主站: Vercel: 适合谁 正在微信小程序技术选型的产品、研发和架构团队。 需要判断 Taro、uni-app、原生小程序、组件库、云开发和 SDK 风险的团队。 需要把历史 awesome 列表转成可筛选、可对比、可验证技术雷达的维护者。 可以什么 Radar:按推荐状态、风险等级、资源类型、分类和适用场景浏览小程序生态资源。 Quick Search:快速搜索资源并跳转常用页面。 Compare:对比 Taro、uni-app、原生小程序等核心方案。 Advisor:输入选型问题,获得推荐结论、适用/不适用条件、迁移成本、下一步和证据来源。 Doctor:粘贴小程序项目配置,识别框架依赖、过时方案和迁移风险。 Weekly:查看小程序生态周报和近期风险信号。 数据概览 当前数据集中包含 236 个小程序生态资源。 完整资源可在 Radar 页面和导出能力中查看。 核心样例 Taro ★30.6k+ - 使用 React 的方式开发小程序的框架,同时支持生成多端应用 uni-app ★36.1k+ - 使用 Vue 语法开发小程序、H5、App的统一框架 MPX ★2.1k+ - 增强型小程序框架,深度性能优化,支持跨小程序平台开发,完全兼容原生小程序组件 WePY ★21.7k+ - 支持组件化的小程序开发框架 vant-weapp ★12.3k+ - 高颜值、好用、易扩展的微信小程序 UI 库 tdesign-miniprogram ★1.3...

28,403

社区成员

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

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