在php中捕获搜索引擎关键字 [英] Capture search engine keywords in php

查看:97
本文介绍了在php中捕获搜索引擎关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在awstats中,我得到了一个表格,其中包含用于查找我的网站的所有关键字和短语.我想自己捕获这个,但是每个搜索引擎URL的格式都不同.当使用google作为引荐来源网址时,我可以使用querystring中的变量q作为搜索词(例如google.com?q=my+keywords),但是另一个搜索引擎的格式可能是searchengine.com?search=my+keywords

In awstats I get a table with all the key words and phrases used to find my website. I would like to capture this myself however each search engine url is in a different format. When google is the referer I can use the variable q from the querystring as the search term (e.g. google.com?q=my+keywords) however another search engine may have the format searchengine.com?search=my+keywords

是否存在识别搜索关键字的通用方法?还是我必须为每个搜索引擎创建一个正则表达式/过滤器?

Is there a generic way of identifying search keywords? Or am I going to have to create a regex/filter for each search engine?

推荐答案

一种可能性是仅获取引用URL($_SERVER['HTTP_REFERER'])并解析其中的关键字.

One possibility is to just grab the referring URL ($_SERVER['HTTP_REFERER']) and parse out the keywords in it.

例如,查看此Google URL(搜索堆栈溢出"):

For example, check out this Google URL (searching for "stack overflow"):

http://www.google.com/search?hl=en&q=stack+overflow&aq=0&oq=stack+over&aqi=g10

q GET变量的值包含用+号分隔的关键字.

The value of the q GET variable holds the keywords delimited by + signs.

这篇关于在php中捕获搜索引擎关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆