各个搜索引擎,获取搜索词的脚本

//正式上线把上网址屏蔽,去掉此行前面代码
function GetQueryString() {
    var refer = document.referrer;
    refer = refer + '&';
    var matches = '';
    if(refer.match(/(www|m|youxuan)\.baidu/)){
        matches = refer.match(/\W(wd|word)\=(.*?)\&/i);
        if(matches){
            matches = matches[2];
        }
    };
    if(refer.match(/m\.sm\.cn/)) {
        matches = refer.match(/q\=(.*?)\&/i);
        if(matches) {
            matches = matches[1];
        }
    };
    if(refer.match(/(www|m)\.sogou/)) {
        matches = refer.match(/\W(query|keyword)\=(.*?)\&/i);
        if(matches) {
            matches = matches[2];
        }
    };
   if(refer.match(/so\.com/)) {
        matches = refer.match(/q\=(.*?)\&/i);
        if(matches) {
            matches = matches[1];
        }
    };
    if(matches && matches.indexOf("%") == 0) {
        matches = decodeURIComponent(matches);
    } else {
        matches = '';
    };

    return matches;
};
var wd = GetQueryString();
if(wd && wd.length > 0){
    wd = decodeURIComponent(wd);
    var line = wd;
}else{
    line = '.';
}

 

posted @ 2020-04-19 13:59  心无引擎,眼无流派  阅读(507)  评论(0编辑  收藏  举报