Code for quick search of network content through ASP programming for instance analysis

Source: Internet
Author: User

One day I had a whim. It would be wonderful if I could immediately call up the information I needed to read on every website. Next I want to think more deeply about this problem. I sat down in a chair and took a pencil, but I don't know what I wrote. As a result, I still have to deal with the code.
My friend opened a small website, which was originally designed by me. This is a good platform to test my ideas. So I wrote the code and uploaded the file. I was so excited that the program was a perfect task and proved that my ideas were indeed good.
I have read some online user preference reports before, and I am very impressed by a rule. If most users cannot find the content they need in three clicks, they will immediately leave the site. My code can solve this problem, and insurance users can find the target by clicking the mouse once. In my example, assume that a user has access to Yahoo and the search keyword is Fireplace Accessories ). In the result, he came to my friend's site and will see a picture of the words "you are searching for Fireplace Accessories. Then, he will follow the prompts on the website and go directly to the desired page.
The first step is to create an initial variable in the global. asa file and place it in your Sub Session_onStart () program. Copy codeThe Code is as follows: Sub Session_onStart ()
Referer = Trim (Request. ServerVariables ("HTTP_REFERER "))
If Referer = "" Then
Referer = "None"
End If
Session ("Referer") = Referer
End Sub

Next, let's take a look at how to complete the main functions of the program.
Because the url is encoded, we need to first restore the pointing data of the visitor's host to something useful for us. Building an ASP page called decode. asp is the backbone of our program. The first function is to decode the encoded header. The program is a little long and straightforward, and there is nothing to blame. If you are too troublesome, it is better to find this article on www.popunet.com's "online worm Training Course" and use the "copy/paste" method.
Source code
The second thing to do is: extract the query part from the URL header information-this is what we need.Copy codeThe Code is as follows: 'separate the query field from the pointing URL.
Function isProduct (pStr)
If pStr <> "" And lCase (pStr) <> "none" Then
'Search for fields backward
Temp = Limit Rev (pStr ,"/")
'Obtain the directory separation location
TempStr = Right (pStr, temp)
'Get the Data Length
Temp2 = Len (pStr)
'Get the queried data row
PStr = Mid (pStr, temp, temp2)
'Set the return function value
IsProduct = pStr
Else
IsProduct = ""
End If
End Function

The next step is to establish clear search criteria. For this purpose, create two static spaces? Search for pointed dataCopy codeThe Code is as follows: Function Finder (byRef prodList, byVal refList)
'Fuzzy Query
RefList = lCase (refList)
'Query matching fields cyclically through pointers
For I = 0 To uBound (prodList)-1
If inStr (refList, lCase (prodList (I, 0) Then
'Find matching
THolder = tHolder & "Are You looking "_
&""_
& ProdList (I, 0 )&"
"
End If
'Second Loop
Next
'Return result
Finder = tHolderEnd Function
Put our decode. asp on any page that requires this function through an inclue.
The details are as follows:
'If lCase (Session ("Referer") <> "none" OR Session ("Referer ") <> "" then' points to the data Response. write vbCrLf &"
"_ & Finder (pArray, URLDecode (isProduct (Session (" Referer "))))_&"
"& VbCrLf
End If

Related Article

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.