ASP network Programming: Using ASP programming to realize network content fast Search

Source: Internet
Author: User

One day I had a whim, if I go to a website, where I can immediately call out the information I need to see, it is not wonderful. Next I wanted to think about it more deeply, to sit in a chair and get a pencil, but I didn't know what I was writing. In this way, I still have to deal with the code.

My friend opened a small site, originally I designed. This is a good platform to test my ideas. So I wrote the code and uploaded the file. It's really exciting, the procedure is perfect, and it proves that my idea is really good.

I've seen some Internet users tend to report, and one of the rules has impressed me very deeply. That is, most users will leave the site immediately if they cannot find what they are looking for within three clicks. My code will be able to address this problem, the insurance users just click the mouse to find the target. In my case, suppose a user on Yahoo, the search keyword for fireplace accessories (Flight equipment Accessories). In the given results, he came to my friend's site, will see "You are searching fireplace accessories" and other words such as the picture. Then he will follow the instructions on the website and go directly to the desired page. "Shanghai Treatment Impotence Hospital"

The first step you make is to create an initial variable in the Global.asa file, placed in your sub Session_OnStart () program.

Sub Session_OnStart ()

Referer = Trim (Request.ServerVariables ("Http_referer"))

If Referer = "Then

Referer = "None"

End If

Session ("Referer") = Referer

End Sub

Then we take a look at how to complete the main function of the program.

Because the URL is encoded, the first thing you need to do is to restore the caller's host data to something that is useful to us. Build an ASP page, call it decode.asp, is the backbone of our program. The first function is to decode the encoded pointing header. The program is a bit long, and very direct, there is no roundabout, if you are too troublesome, rather to www.popunet.com "network worm refresher courses" above to find this article, with "Copy/paste" Dafa bar.

Source

The second thing to do is to isolate the query part from the URL header-This is what we need.

' Detach the Query field from the point URL.

Function isproduct (PSTR)

If pStr <> "and LCase (PSTR) <>" None "then

' Search Fields backwards

temp = InStrRev (pStr, "/")

' Get the Directory separated location

TempStr = right (pStr, temp)

' Get the relevant data length

Temp2 = Len (PSTR)

' Get query data rows

PSTR = Mid (pStr, temp, TEMP2)

' Sets the value of the return function

Isproduct = PStr

Else

Isproduct = ""

End If

End Function

The next is to establish clear criteria for finding. To achieve this, create two static spaces "refer to the data

Function Finder (ByRef prodlist, ByVal reflist)

' Fuzzy query

reflist = LCase (reflist)

' Loop through the pointer to find matching fields

For i = 0 to UBound (prodlist)-1

If inStr (reflist, LCase (prodlist (i, 0)) Then

' Find a match

Tholder = Tholder & "is looking for" _

& "" _

& Prodlist (i, 0) & "

"

End If

' Second cycle

Next

' Return results

Finder = Tholderend Function

With a inclue, we put our good decode.asp on any page that needs this function.

Specific as follows:

' If the pointing header is not empty, bring up this function if LCase (session ("Referer")) <> "None" OR Session ("Referer") <> "then" to resolve the point to the data Response.Write VbCrLf & "

_ & Finder (Parray, UrlDecode (Isproduct (Session ("Referer"))) _ & "

"& VbCrLf

End If

ASP network Programming: Using ASP programming to realize network content fast Search

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.