This site provides users with the information about asp, search engine query keyword, how to get search engine query keywords, how to get google query keywords, retrieve yahoo search query keywords, get bing search query keywords, get search engine referrer information, get search engine referer keywords, url encoding, url decoding, urlencoding, urldecoding, and more.
If you think that this site is helpful, please recommend your friends to visit our site.
asp: how to get search engine query keywords?
There are three methods that you can use to get search engine referrer query keywords. The first is to use "request.querystring" without parameter, the second is to use "request.querystring" with parameter, and the last is to use your own querystring. Let's have a look at them one after another in the following:
1. Use "request.querystring" without parameter
For using this method, you need to use string manipulation methods like "mid", "left", "right", "instr", or "instrrev". Let's see an example:
The query you got:
http://ca.search.yahoo.com/search;_ylt=A0geu8BhMQdPw2UAH9brFAx.?p=test+code&fr2=sb-top&fr=yfp-t-715&type_param=&rd=r1
The method you use:
search_engine =mid(request.querystring, instr(request.querystring, "p=")+2, len(request.querystring))
search_engine = left(search_engine, instr(search_engine, "&"))
Please note that if the query was encoded, you need to use the following urldecode function to decode the encoded query:
Function URLDecode(s_Convert)
Dim s_Split
Dim s_Output
Dim I
on error resume next
If IsNull(s_Convert) Then
URLDecode = ""
Exit Function
End If
s_Output = REPLACE(s_Convert, "+", " ")
s_Split = Split(s_Output, "%")
If IsArray(s_Split) Then
s_Output = s_Split(0)
For I = 0 to UBound(s_Split) - 1
s_Output = s_Output & _
Chr("&H" & Left(s_Split(i + 1), 2)) & _
Right(s_Split(i + 1), Len(s_Split(i + 1)) - 2)
Next
End If
s_Decoded = s_Output
End Function
For encoding, use the following code:
Server.URLEncode(s_query)
2. Use "request.querystring" with parameter
For using this method, you first need to find out "URL parameter" and then use the following code:
request.querystring("q") 'for google
The following are the parameters for major search engines:
1) Google
http://www.google.ca/search?sourceid=chrome&ie=UTF-8&q=test+code#sclient=psy-ab&hl=en&
source=hp&q=test+code&pbx=1&oq=test+code&aq=f&aqi=&aql=&gs_sm=s&
gs_upl=0l0l0l1190l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.,cf.osb&
fp=45b2d8cdbabb18d&biw=1066&bih=780
The parameter for search keywords is "q"
2) Yahoo
http://ca.search.yahoo.com/search;_ylt=A0geu8BhMQdPw2UAH9brFAx.?p=test+code&fr2=sb-top&fr=yfp-t-715&type_param=&rd=r1
The parameter for search keywords is "p"
3) Bing
http://www.bing.com/search?q=test+code&go=&qs=bs&form=QBRE&filt=all
The parameter for search keywords is "q"
4) AOL
http://search.aol.ca/aol/search?invocationType=topsearchbox.search&query=test+code&rp=
The parameter for search keywords is "query"
5) Baidu
http://www.baidu.com/s?bs=test+code&f=8&rsv_bp=1&rsv_spt=3&wd=test+code&inputT=0
The parameter for search keywords is "wd"
3. Use your own querystring
You can also use your own querystring to get the search keywords like the following:
http://www.yourdomain.com/test.asp?test=http://search.aol.ca/aol/search?invocationType=topsearchbox.search&query=test+code&rp=
If the other two methods fail, you can use this method to obtain the search keywords. After getting the query string, you can use method 1 to get the search keywords.
|