Using ASP programming to realize fast searching of network content

Source: Internet
Author: User
Tags end header query return
Programming | Network One day I had a sudden whim, and it would be wonderful if I could immediately pull out the information I needed to see on every website. Next I want to think about this more deeply, sit in a chair and get a pencil, but I don't know what I'm writing. In this way, I still have to deal with the code.

My friend opened a small site, was originally designed by me. This is a good platform to test my ideas. So I wrote the code and uploaded the file. It was so exciting that the procedure worked perfectly, and it proved that I had a good idea indeed.

I have seen a number of Internet user tendencies reported before, and one of them is a rule that impresses me deeply. Said most users will leave the site immediately if they cannot find what they want within three clicks. My code will be able to address this problem, and the insurance user can find the target with just one click of the mouse. In my case, suppose a user is on Yahoo, and the search keyword is fireplace accessories (Flight accessories). In the results given, he came to my friend's site, will see "You are searching for fireplace accessories" and so on the screen. He then follows the prompts on the website and goes directly to the desired page.

The first step you want to make is to create an initial variable in the Global.asa file and place it 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 let's take a look at how to complete the main function of the program.

Because the URL has been encoded, so first of all, the visitors to the host to restore the data to our useful things. Create an ASP page, call it decode.asp, is the backbone of our program. The first function is to decode the encoded pointing head. The program is a bit long, and very direct, there is no roundabout, if you are too troublesome, as to www.popunet.com "nets bug refresher Course" above find this article, with "Copy/paste" Dafa bar.

Source code

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

' Detach the query field from point to URL.
function isproduct (PSTR)
if pstr <> "" and LCase (PSTR) <> "None" Then
Search Back Fields
temp = InStrRev (Pstr, "/")
"Get the location of directory separation
tempstr = right (pstr, temp)
' Get relevant data length
TEMP2 = Len (PSTR)
' Get query data rows
pstr = Mid (pstr, temp, TEMP2)
' Set the return function value
isproduct = Pstr
else
isproduct = ""
end If
end Function
The next is to establish a clear standard of search. To achieve this, create two static spaces. Find points to data

function Finder (ByRef prodlist, ByVal reflist)
' Fuzzy query
reflist = LCase (reflist)
' Find matching field by pointer loop
for i = 0 to UBound (prodlist)-1
if inStr (reflist, LCase (prodlist (i, 0)) Then
' Find a match
tholder = Tholder & "Are You Looking for" _
& "" _
& prodlist (i, 0) & "
£ "
end If
' Second cycle
next
' Return results
finder = Tholderend Function

Through a inclue, put our good decode.asp to any page that needs this function, it's done.

Specifically as follows:

' If the pointing header is not empty, call this feature if LCase (Session ("Referer")) <> "None" OR session ("Referer") <> "Then" Parse point to data Response.Write VbCrLf & "

£ "_ & Finder (Parray, UrlDecode (isproduct (" 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.