解析搜索引擎关键词
我试图找到最有效的方法来解析我的 System.Web.HTTPRequest.UrlReferrer,以找到用于将访问者吸引到我的网站的搜索词(假设他们通过搜索引擎结果页面到达我的网站)。
我想(希望)我会使用 HttpUtility.ParseQueryString 方法,但我的问题在于试图找出要解析的变量。我有以下需要检查的清单。该列表显示了搜索引擎和每个搜索引擎使用的参数。
daum:q,
eniro:search_word,
naver:query,
images.google:q,
google:q,
yahoo:p,
msn:q,
bing:q,
aol:query,
aol:encquery,
lycos:query,
ask:q,
altavista:q,
netscape:query,
cnn:query,
about:terms,
mamma:query,
alltheweb:q,
voila:rdata,
virgilio:qs,
live:q,
baidu:wd,
alice:qs,
yandex:text,
najdi:q,
aol:q,
mama:query,
seznam:q,
search:q,
wp:szukaj,
onet:qt,
szukacz:q,
yam:k,
pchome:q,
kvasir:q,
sesam:q,
ozu:q,
terra:query,
mynet:q,
ekolay:q,
rambler:words
因此,虽然我可以仔细检查每一个并说一些类似
NameValueCollection query = HttpUtility.ParseQueryString(UrlReferrer);
var referrer = Request.UrlReferrer.ToString();
if(referrer.Contains("google.com")
return (query["q"]);
else if(referrer.Contains("yahoo.com")
return (query["p"]);
我认为必须有更好的方法,因为我有这个很好的名称/值对来工作,以及 ParseQueryString 方法的强大功能,但我却一片空白。
I am trying to find the most effective way to parse my System.Web.HTTPRequest.UrlReferrer to find the search term that was used to drive the visitor to my site assuming they arrived at my site via a search engine results page.
I am thinking (hoping) I'd use the HttpUtility.ParseQueryString method, but my problem comes in trying to figure out what variable to parse for. I have the following list that I am required to check for. The list shows the search engine and the param that each uses.
daum:q,
eniro:search_word,
naver:query,
images.google:q,
google:q,
yahoo:p,
msn:q,
bing:q,
aol:query,
aol:encquery,
lycos:query,
ask:q,
altavista:q,
netscape:query,
cnn:query,
about:terms,
mamma:query,
alltheweb:q,
voila:rdata,
virgilio:qs,
live:q,
baidu:wd,
alice:qs,
yandex:text,
najdi:q,
aol:q,
mama:query,
seznam:q,
search:q,
wp:szukaj,
onet:qt,
szukacz:q,
yam:k,
pchome:q,
kvasir:q,
sesam:q,
ozu:q,
terra:query,
mynet:q,
ekolay:q,
rambler:words
So while I could go through each and say something like
NameValueCollection query = HttpUtility.ParseQueryString(UrlReferrer);
var referrer = Request.UrlReferrer.ToString();
if(referrer.Contains("google.com")
return (query["q"]);
else if(referrer.Contains("yahoo.com")
return (query["p"]);
I'm thinking there must be a better way since I have this nice name/value pair to work against,and the power of the ParseQueryString method, but I'm drawing a blank.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,我对此并不满意,而且我认为我没有实现效率,但这就是我最终所做的。我仍然很想听到你们提出更好的方法。
Well, I am not happy with it, and I don't think I achieved efficiency, but this is what I ended up doing. I'd still love to hear from you guys with better approaches.