SoFunction
Updated on 2025-04-13

Use ASP to do a TOP COOL site search

The search engine consists of an HTM file and an ASP file. It mainly uses the FILESYSTEMOBJECT component to achieve its purpose. It has powerful functions and can be used directly after modifying the interface. Of course, it is even better to add a little of your own things.


This HTM file is used to pass in the condition

<HTML>
<HEAD>
<TITLE>ASP Search Engine Example</TITLE>
</HEAD>
<BODY>
<CENTER>
<FORM METHOD=POST ACTION="">

<TABLE BGCOLOR="#CC6633" BORDER="0">
<TR>

<TD ROWSPAN="3" BGCOLOR="#CC6633" width="21" nowrap> </TD>

<TD width="363" nowrap> <FONT COLOR="#FFFFFF">
<INPUT TYPE="text" NAME="SearchText" SIZE="22">
<INPUT TYPE="checkbox" NAME="Case">
Highly sensitive</FONT> </TD>

<TD ROWSPAN="3" width="10">
<INPUT TYPE="submit" VALUE="OK">
<P>

<INPUT TYPE="reset" VALUE="Clear">
</TD>

<TD ROWSPAN="3" BGCOLOR="#CC6633" width="28"> </TD>
</TR>
<TR>

<TD width="363" nowrap> <FONT COLOR="#FFFFF"> Return result
<SELECT name="rLength" >
<option value="200" selected>Long message </option>
<option value="100">Short message</option>
<option value="0">Return only to the connection</option>
</SELECT>
<SELECT NAME="rResults">
<OPTION VALUE="10" SELECTED>10
<OPTION VALUE="25">25
<OPTION VALUE="50">50
</SELECT>
</FONT>
</TD>
</TR>
<TR>

<TD width="363" nowrap> <FONT COLOR="#FFFFF"> Must include:
<INPUT TYPE="checkbox" NAME="iImage">
picture
<INPUT TYPE="checkbox" NAME="iZips">
Zip format
<INPUT TYPE="checkbox" NAME="iJavaS"> JavaScript
</FONT>
</TD>
</TR>
</TABLE>
</FORM>
</CENTER>

<DL>
<DD> </DD>
</DL>
</BODY>
</HTML>

------------------------------------------------------------------------
ASP program that displays results


<HTML>
<HEAD>
Search results for <TITLE>'<%=Request("SearchText")%>'</TITLE>
</HEAD>
<BODY>
Search results for <B>'<%=Request("SearchText")%>'</B><BR>
<%
Const fsoForReading = 1
Dim objFile, objFolder, objSubFolder, objTextStream
Dim bolCase, bolFileFound, bolTagFound
Dim strCount, strDeTag, strExt, strFile, strContent, strRoot, strTag, strText, strTitle, strTitleL
Dim reqImage, reqJavaS, reqLength, reqNumber, reqZip

strFile = ".asp .htm .html .js .txt .css"
strRoot = "/"
strText = Request("SearchText")
strTag = Chr(37) & Chr(62)
bolFileFound = False
bolTagFound = False
If Request("Case") = "on" Then bolCase = 0 Else bolCase = 1
If Request("iImage") = "on" Then reqImage = "<IMG" Else reqImage = ""
If Request("iZips") = "on" Then reqZips = ".zip" Else reqImage = ""
If Request("iJavaS") = "on" Then reqJavaS = "JavaScript" Else reqImage = ""
If Request("rResults") = "10" Then reqNumber = 10
If Request("rResults") = "25" Then reqNumber = 25
If Request("rResults") = "50" Then reqNumber = 50
reqLength = Request("rLength")

Set objFSO = ("")
Set objFolder = ((strRoot))

schSubFol(objFolder)

Sub schSubFol(objFolder)
For Each objFile in
If strCount + 1 > reqNumber or strText = "" Then Exit Sub
If Then
Set objTextStream = (,fsoForReading)

strContent =

If InStr(1, strContent, strTag, bolCase) Then
Else
If Mid(, Len() - 1, 1) = "." Then strExt = Mid(, Len() - 1, 2)
If Mid(, Len() - 2, 1) = "." Then strExt = Mid(, Len() - 2, 3)
If Mid(, Len() - 3, 1) = "." Then strExt = Mid(, Len() - 3, 4)
If Mid(, Len() - 4, 1) = "." Then strExt = Mid(, Len() - 4, 5)
If InStr(1, strContent, strText, bolCase) And _
InStr(1, strContent, reqImage, 1) And _
InStr(1, strContent, reqZips, 1) And _
InStr(1, strContent, reqJavaS, 1) And _
Instr(1, strFile, strExt, 1) Then
If InStr(1, strContent, "<TITLE>", 1) Then strTitle = Mid(strContent, InStr(1, strContent, "<TITLE>", 1) + 7, InStr(1, strContent, "</TITLE>", 1)) Else strTitle = "Unnamed"

strCount = strCount + 1
"<DL><DT><B><I>"& strCount &"</I></B> - <A HREF=" & & ">" & strTitle & "</A></A></DT><BR><DD>"
strTitleL = InStr(1, strContent, "</TITLE>", 1) - InStr(1, strContent, "<TITLE>", 1) + 7

strDeTag = ""
bolTagFound = False

Do While InStr(strContent, "<")
bolTagFound = True
strDeTag = strDeTag & " " & Left(strContent, InStr(strContent, "<") - 1)
strContent = MID(strContent, InStr(strContent, ">") + 1)
Loop

strDeTag = strDeTag & strContent
If Not bolTagFound Then strDeTag = strContent

If reqLength = "0" Then & "</DD></DL>" Else Mid(strDeTag, strTitleL, reqLength) & "...<BR><b><FONT SIZE='2'>URL: " & & " - Last modified time: " & & " - " & FormatNumber( / 1024) & "Kbytes</FONT></b></DD></DL>"
bolFileFound = True
End If

End If
End If
Next
End Sub

For Each objSubFolder in
schSubFol(objSubFolder)
Next

If Not bolFileFound then "No matching result"
If bolFileFound then "<B>Search End</B>"

Set objTextStream = Nothing
Set objFolder = Nothing
Set objFSO = Nothing
%>
</BODY></HTML>